You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2022/07/06 16:44:49 UTC
[airflow] branch main updated: Revert "KubernetesExecutor: Use user-provided namespace from executor_config arg (#24342)" (#24879)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 40fde0013e Revert "KubernetesExecutor: Use user-provided namespace from executor_config arg (#24342)" (#24879)
40fde0013e is described below
commit 40fde0013ee1ce55405125f1897e8f464fa3811d
Author: Jarek Potiuk <ja...@polidea.com>
AuthorDate: Wed Jul 6 18:44:40 2022 +0200
Revert "KubernetesExecutor: Use user-provided namespace from executor_config arg (#24342)" (#24879)
This reverts commit 1fe07e5cebac5e8a0b3fe7e88c65f6d2b0c2134d.
---
airflow/kubernetes/pod_generator.py | 14 ++------------
tests/kubernetes/test_pod_generator.py | 5 ++---
2 files changed, 4 insertions(+), 15 deletions(-)
diff --git a/airflow/kubernetes/pod_generator.py b/airflow/kubernetes/pod_generator.py
index 133f59220c..705c108b79 100644
--- a/airflow/kubernetes/pod_generator.py
+++ b/airflow/kubernetes/pod_generator.py
@@ -335,10 +335,6 @@ class PodGenerator:
- airflow.cfg
- executor_config
- dynamic arguments
-
- If a user provides a `pod_override_object`, that pod should only be able to
- override the image and namespace, and not arbitrary labels / annotations of
- the dynamic_pod.
"""
try:
image = pod_override_object.spec.containers[0].image # type: ignore
@@ -346,12 +342,6 @@ class PodGenerator:
image = kube_image
except Exception:
image = kube_image
- try:
- final_namespace = pod_override_object.metadata.namespace # type: ignore
- if not final_namespace:
- final_namespace = namespace
- except Exception:
- final_namespace = namespace
annotations = {
'dag_id': dag_id,
@@ -378,7 +368,7 @@ class PodGenerator:
dynamic_pod = k8s.V1Pod(
metadata=k8s.V1ObjectMeta(
- namespace=final_namespace,
+ namespace=namespace,
annotations=annotations,
name=PodGenerator.make_unique_pod_id(pod_id),
labels=labels,
@@ -396,7 +386,7 @@ class PodGenerator:
)
# Reconcile the pods starting with the first chronologically,
- # Pod from the pod_template_file -> Pod from executor_config arg -> Pod from dynamic arguments
+ # Pod from the pod_template_File -> Pod from executor_config arg -> Pod from the K8s executor
pod_list = [base_worker_pod, pod_override_object, dynamic_pod]
try:
diff --git a/tests/kubernetes/test_pod_generator.py b/tests/kubernetes/test_pod_generator.py
index 6c87efa478..df5efb0d06 100644
--- a/tests/kubernetes/test_pod_generator.py
+++ b/tests/kubernetes/test_pod_generator.py
@@ -414,8 +414,7 @@ class TestPodGenerator:
name='', resources=k8s.V1ResourceRequirements(limits={'cpu': '1m', 'memory': '1G'})
)
]
- ),
- metadata=k8s.V1ObjectMeta(namespace='overridden_namespace'),
+ )
)
result = PodGenerator.construct_pod(
@@ -436,7 +435,7 @@ class TestPodGenerator:
expected.metadata.labels['app'] = 'myapp'
expected.metadata.annotations = self.annotations
expected.metadata.name = 'pod_id-' + self.static_uuid.hex
- expected.metadata.namespace = 'overridden_namespace'
+ expected.metadata.namespace = 'test_namespace'
expected.spec.containers[0].args = ['command']
expected.spec.containers[0].image = expected_image
expected.spec.containers[0].resources = {'limits': {'cpu': '1m', 'memory': '1G'}}