Skip to content

Commit d39197f

Browse files
dstandishephraimbuddy
authored andcommitted
Remove RefreshConfiguration workaround for K8s token refreshing (#20759)
A workaround was added (#5731) to handle the refreshing of EKS tokens. It was necessary because of an upstream bug. It has since been fixed (kubernetes-client/python-base@70b78cd) and released in v21.7.0 (https://github.com/kubernetes-client/python/blob/master/CHANGELOG.md#v2170). (cherry picked from commit 7bd165f)
1 parent 3d2c02e commit d39197f

File tree

20 files changed

+1222
-535
lines changed

20 files changed

+1222
-535
lines changed

UPDATING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,14 @@ https://developers.google.com/style/inclusive-documentation
8181
8282
-->
8383

84+
## Airflow 2.2.5
85+
86+
### Minimum kubernetes version bumped from 3.0.0 to 21.7.0
87+
88+
No change in behavior is expected. This was necessary in order to take advantage of a [bugfix](https://github.com/kubernetes-client/python-base/commit/70b78cd8488068c014b6d762a0c8d358273865b4) concerning refreshing of Kubernetes API tokens with EKS, which enabled the removal of some [workaround code](https://github.com/apache/airflow/pull/20759).
89+
90+
### Deprecation: `Connection.extra` must be JSON-encoded dict
91+
8492
## Airflow 2.2.4
8593

8694
### Smart sensors deprecated

airflow/kubernetes/kube_client.py

Lines changed: 10 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -25,39 +25,10 @@
2525
try:
2626
from kubernetes import client, config
2727
from kubernetes.client import Configuration
28-
from kubernetes.client.api_client import ApiClient
2928
from kubernetes.client.rest import ApiException
3029

31-
from airflow.kubernetes.refresh_config import RefreshConfiguration, load_kube_config
32-
3330
has_kubernetes = True
3431

35-
def _get_kube_config(
36-
in_cluster: bool, cluster_context: Optional[str], config_file: Optional[str]
37-
) -> Optional[Configuration]:
38-
if in_cluster:
39-
# load_incluster_config set default configuration with config populated by k8s
40-
config.load_incluster_config()
41-
return None
42-
else:
43-
# this block can be replaced with just config.load_kube_config once
44-
# refresh_config module is replaced with upstream fix
45-
cfg = RefreshConfiguration()
46-
load_kube_config(client_configuration=cfg, config_file=config_file, context=cluster_context)
47-
return cfg
48-
49-
def _get_client_with_patched_configuration(cfg: Optional[Configuration]) -> client.CoreV1Api:
50-
"""
51-
This is a workaround for supporting api token refresh in k8s client.
52-
53-
The function can be replace with `return client.CoreV1Api()` once the
54-
upstream client supports token refresh.
55-
"""
56-
if cfg:
57-
return client.CoreV1Api(api_client=ApiClient(configuration=cfg))
58-
else:
59-
return client.CoreV1Api()
60-
6132
def _disable_verify_ssl() -> None:
6233
configuration = Configuration()
6334
configuration.verify_ssl = False
@@ -130,17 +101,19 @@ def get_kube_client(
130101
if not has_kubernetes:
131102
raise _import_err
132103

133-
if not in_cluster:
134-
if cluster_context is None:
135-
cluster_context = conf.get('kubernetes', 'cluster_context', fallback=None)
136-
if config_file is None:
137-
config_file = conf.get('kubernetes', 'config_file', fallback=None)
138-
139104
if conf.getboolean('kubernetes', 'enable_tcp_keepalive'):
140105
_enable_tcp_keepalive()
141106

142107
if not conf.getboolean('kubernetes', 'verify_ssl'):
143108
_disable_verify_ssl()
144109

145-
client_conf = _get_kube_config(in_cluster, cluster_context, config_file)
146-
return _get_client_with_patched_configuration(client_conf)
110+
if in_cluster:
111+
config.load_incluster_config()
112+
else:
113+
if cluster_context is None:
114+
cluster_context = conf.get('kubernetes', 'cluster_context', fallback=None)
115+
if config_file is None:
116+
config_file = conf.get('kubernetes', 'config_file', fallback=None)
117+
config.load_kube_config(config_file=config_file, context=cluster_context)
118+
119+
return client.CoreV1Api()

airflow/kubernetes/refresh_config.py

Lines changed: 0 additions & 124 deletions
This file was deleted.

0 commit comments

Comments
 (0)