Skip to content

Mapped KubernetesPodOperater not rendering nested templates #25588

@bdsoha

Description

@bdsoha

Apache Airflow version

2.3.3

What happened

Nested values, such as env_vars for the KubernetesPodOperater are not being rendered when used as a dynamically mapped operator.

Assuming the following:

op = KubernetesPodOperater.partial(
    env_vars=[k8s.V1EnvVar(name='AWS_ACCESS_KEY_ID', value='{{ var.value.aws_access_key_id }}')],
    # Other arguments
).expand(arguments=[[1], [2]])

The Rendered Template results for env_vars should be:

("[{'name': 'AWS_ACCESS_KEY_ID', 'value': 'some-super-secret-value', 'value_from': None}]")

Instead the actual Rendered Template results for env_vars are un-rendered:

("[{'name': 'AWS_ACCESS_KEY_ID', 'value': '{{ var.value.aws_access_key_id }}', 'value_from': None}]")

This is probably caused by the fact that MappedOperator is not calling KubernetesPodOperater._render_nested_template_fields.

What you think should happen instead

No response

How to reproduce

No response

Operating System

Ubuntu 18.04

Versions of Apache Airflow Providers

No response

Deployment

Other 3rd-party Helm chart

Deployment details

No response

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions