You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Following is console log from google chrome browser when opening Gantt chart page
which refers to this line of code
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),
)
}
)
Apache Airflow version
2.2.2
What happened
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.
Following is console log from google chrome browser when opening Gantt chart page
which refers to this line of code
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:
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.
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?
Code of Conduct
The text was updated successfully, but these errors were encountered: