diff --git a/airflow/kubernetes/pod_generator.py b/airflow/kubernetes/pod_generator.py index 133f59220cc71..705c108b79da6 100644 --- a/airflow/kubernetes/pod_generator.py +++ b/airflow/kubernetes/pod_generator.py @@ -335,10 +335,6 @@ def construct_pod( - 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 @@ def construct_pod( 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 @@ def construct_pod( 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 @@ def construct_pod( ) # 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 6c87efa478a0e..df5efb0d06c9f 100644 --- a/tests/kubernetes/test_pod_generator.py +++ b/tests/kubernetes/test_pod_generator.py @@ -414,8 +414,7 @@ def test_construct_pod(self, mock_uuid, config_image, expected_image): name='', resources=k8s.V1ResourceRequirements(limits={'cpu': '1m', 'memory': '1G'}) ) ] - ), - metadata=k8s.V1ObjectMeta(namespace='overridden_namespace'), + ) ) result = PodGenerator.construct_pod( @@ -436,7 +435,7 @@ def test_construct_pod(self, mock_uuid, config_image, expected_image): 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'}}