Skip to content

Commit

Permalink
36888-Fix k8 configmap issue in 7.14.0rc1 (apache#37001)
Browse files Browse the repository at this point in the history
  • Loading branch information
vizeit authored Jan 26, 2024
1 parent 0b680c9 commit dd627d7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions airflow/providers/cncf/kubernetes/operators/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class KubernetesPodOperator(BaseOperator):
"volumes",
"volume_mounts",
"cluster_context",
"configmaps",
"env_from",
)
template_fields_renderers = {"env_vars": "py"}

Expand Down Expand Up @@ -313,9 +313,8 @@ def __init__(
if pod_runtime_info_envs:
self.env_vars.extend([convert_pod_runtime_info_env(p) for p in pod_runtime_info_envs])
self.env_from = env_from or []
self.configmaps = configmaps
if self.configmaps:
self.env_from.extend([convert_configmap(c) for c in self.configmaps])
if configmaps:
self.env_from.extend([convert_configmap(c) for c in configmaps])
self.ports = [convert_port(p) for p in ports] if ports else []
self.volume_mounts = [convert_volume_mount(v) for v in volume_mounts] if volume_mounts else []
self.volumes = [convert_volume(volume) for volume in volumes] if volumes else []
Expand Down Expand Up @@ -420,6 +419,10 @@ def _render_nested_template_fields(
template_fields = ("claim_name",)
elif isinstance(content, k8s.V1ConfigMapVolumeSource):
template_fields = ("name",)
elif isinstance(content, k8s.V1EnvFromSource):
template_fields = ("config_map_ref",)
elif isinstance(content, k8s.V1ConfigMapEnvSource):
template_fields = ("name",)
else:
template_fields = None

Expand Down
2 changes: 1 addition & 1 deletion tests/providers/cncf/kubernetes/operators/test_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_templates(self, create_task_instance_of_operator):
assert dag_id == ti.task.arguments
assert dag_id == ti.task.env_vars[0]
assert dag_id == rendered.annotations["dag-id"]
assert dag_id == ti.task.configmaps[0]
assert dag_id == ti.task.env_from[0].config_map_ref.name
assert dag_id == rendered.volumes[0].name
assert dag_id == rendered.volumes[0].config_map.name

Expand Down

0 comments on commit dd627d7

Please sign in to comment.