Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gantt chart doesn't show up #22702

Closed
1 of 2 tasks
karunpoudel opened this issue Apr 1, 2022 · 1 comment
Closed
1 of 2 tasks

Gantt chart doesn't show up #22702

karunpoudel opened this issue Apr 1, 2022 · 1 comment
Labels
area:core kind:bug This is a clearly a bug

Comments

@karunpoudel
Copy link
Contributor

karunpoudel commented Apr 1, 2022

Apache Airflow version

2.2.2

What happened

image

Gantt chart doesn't show up if you provide vault annotation in executor_config in your task. Vault annotation generally needs a template string where you need to use double quotes and newline like shown below.
image

Following is console log from google chrome browser when opening Gantt chart page
image
which refers to this line of code
image

Browser is not able to parse the json string because it not generated correctly to handle backslash that might show up in taskinstance log (as shown above).

This throws error:

JSON.parse('{"vault.hashicorp.com/agent-inject-template-artifactory":"\n      {{- with secret \"secret/data/nastdomains/artifactory\" -}}\n      {{- .Data.data | toJSON -}}\n      {{- end }}"}')
Unexpected token in JSON at position 58

What you think should happen instead

The taskinstance result should be properly escaped for backslash character when writing to html document.
Instead of exporting
{"vault.hashicorp.com/agent-inject-template-artifactory": "\n {{- with secret \"path/to/secrets\" -}}\n {{- .Data.data | toJSON -}}\n {{- end }}"}
it should be exported as
{"vault.hashicorp.com/agent-inject-template-artifactory": "\\n {{- with secret \\"path/to/secrets\\" -}}\\n {{- .Data.data | toJSON -}}\\n {{- end }}"}
So that is can be correctly consumed by JSON.parse() javascript function.

How to reproduce

Create a DAG with following code. Trigger the DAG. After it completes (either success or failure), go to Gantt view.

from airflow import DAG
from airflow.operators.dummy import DummyOperator
from kubernetes.client import models as k8s
import pendulum

annotations = {
    'vault.hashicorp.com/agent-inject': 'true',
    'vault.hashicorp.com/role': f'vault-role',
    'vault.hashicorp.com/agent-pre-populate-only': 'true',
    f'vault.hashicorp.com/agent-inject-secret-filename': 'path/to/secret',
    f'vault.hashicorp.com/agent-inject-template-filename': f"""
      {{{{- with secret "path/to/secret" -}}}}
      {{{{- .Data | toJSON -}}}}
      {{{{- end }}}}"""
}

dag = DAG(
    dag_id="example2",
    start_date=pendulum.datetime(2021, 1, 1),
    schedule_interval=None,
    max_active_runs=1,
    catchup=False,
)

with dag:
    t0 = DummyOperator(
        task_id='start',
        executor_config={
            "pod_override": k8s.V1Pod(
                metadata=k8s.V1ObjectMeta(annotations=annotations),
            )
        }
    )

Operating System

Debian GNU/Linux 11 (bullseye)

Versions of Apache Airflow Providers

apache-airflow-providers-cncf-kubernetes==1!2.1.0

Deployment

Astronomer

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

@uranusjr
Copy link
Member

uranusjr commented Apr 6, 2022

I think this is fixed right?

@uranusjr uranusjr closed this as completed Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core kind:bug This is a clearly a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants