Skip to content

Commit b3e648c

Browse files
authored
Merge pull request #10 from LamaAni/fix_packages
Fix packages
2 parents 45a404b + d74c34e commit b3e648c

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

Pipfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ verify_ssl = true
77
pytest = "*"
88
black = "*"
99
flake8 = "*"
10+
apache-ariflow = "==1.10.9"
11+
airflow-kubernetes-job-operator = {path = "."}
1012

1113
[packages]
1214
pyyaml = ">=5.0"
13-
kubernetes = ">=9.0.0"
15+
kubernetes = ">=8.0.1"
1416
urllib3 = ">=1.25.0"
1517
zthreading = ">=0.1.13"
1618
python-dateutil = "*"

airflow_kubernetes_job_operator/kube_api/client.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def __init__(
6666
auto_reconnect: bool = False,
6767
auto_reconnect_max_attempts: int = DEFAULT_AUTO_RECONNECT_MAX_ATTEMPTS,
6868
auto_reconnect_wait_between_attempts: float = DEFAULT_AUTO_RECONNECT_WAIT_BETWEEN_ATTEMPTS,
69+
always_throw_on_first_api_call: bool = True,
6970
):
7071
assert use_asyncio is not True, NotImplementedError("AsyncIO not yet implemented.")
7172
super().__init__(
@@ -87,6 +88,7 @@ def __init__(
8788
self.auto_reconnect = auto_reconnect
8889
self.auto_reconnect_max_attempts = auto_reconnect_max_attempts
8990
self.auto_reconnect_wait_between_attempts = auto_reconnect_wait_between_attempts
91+
self.always_throw_on_first_api_call = always_throw_on_first_api_call
9092

9193
# these event are object specific
9294
self.query_started_event_name = f"{self.query_started_event_name} {id(self)}"
@@ -257,9 +259,10 @@ def can_reconnect(message=None):
257259
exception_message = (
258260
f"{ex.reason}, {exception_details.get('reason')}: {exception_details.get('message')}"
259261
)
260-
if can_reconnect(True, exception_message):
262+
force_throw = self.always_throw_on_first_api_call and total_reconnects == 0
263+
if not force_throw and can_reconnect(exception_message):
261264
continue
262-
if self.query_running and not self._is_being_stopped:
265+
if force_throw or self.query_running and not self._is_being_stopped:
263266
raise KubeApiClientException(exception_message, inner_exception=ex)
264267
else:
265268
raise ex
@@ -405,7 +408,7 @@ def load_kubernetes_configuration_from_file(
405408
)
406409

407410
configuration = kube_config.Configuration()
408-
411+
configuration.filepath = None
409412
if is_in_cluster and config_file is None:
410413
# load from cluster.
411414
loader = incluster_config.InClusterConfigLoader(
@@ -423,7 +426,8 @@ def load_kubernetes_configuration_from_file(
423426
DEFAULT_KUBE_CONFIG_LOCATIONS,
424427
)
425428
for loc in config_possible_locations:
426-
if os.path.isfile(expanduser(loc)):
429+
loc = expanduser(loc)
430+
if os.path.isfile(loc):
427431
config_file = loc
428432

429433
assert config_file is not None, "Kubernetes config file not provided and default config could not be found."

airflow_kubernetes_job_operator/kube_api/queries.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def __init__(
168168
"watch": watch,
169169
},
170170
auto_reconnect=watch,
171+
always_throw_on_first_api_call=name is None,
171172
)
172173
self.kind = kind
173174
self.namespace = namespace

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def get_version():
4343
license="LICENSE",
4444
install_requires=[
4545
"PyYAML>=5.0",
46-
"kubernetes>=9.0.0",
46+
"kubernetes>=8.0.1",
4747
"urllib3>=1.25.0",
4848
"zthreading>=0.1.13",
4949
"python-dateutil>=2.8.1",

0 commit comments

Comments
 (0)