Skip to content

Commit 0f07382

Browse files
authored
fix: error on delete argo deployment when template missing (#2593)
1 parent 8dd5ed1 commit 0f07382

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

metaflow/plugins/argo/argo_workflows.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,17 @@ def list_templates(flow_name, all=False, page_size=100):
258258
def delete(name):
259259
client = ArgoClient(namespace=KUBERNETES_NAMESPACE)
260260

261-
workflow_template = client.get_workflow_template(name)
261+
# the workflow template might not exist, but we still want to try clean up associated sensors and schedules.
262+
workflow_template = client.get_workflow_template(name) or {}
263+
workflow_annotations = workflow_template.get("metadata", {}).get(
264+
"annotations", {}
265+
)
266+
262267
sensor_name = ArgoWorkflows._sensor_name(
263-
workflow_template["metadata"]["annotations"].get(
264-
"metaflow/sensor_name", name
265-
)
268+
workflow_annotations.get("metaflow/sensor_name", name)
266269
)
267270
# if below is missing then it was deployed before custom sensor namespaces
268-
sensor_namespace = workflow_template["metadata"]["annotations"].get(
271+
sensor_namespace = workflow_annotations.get(
269272
"metaflow/sensor_namespace", KUBERNETES_NAMESPACE
270273
)
271274

0 commit comments

Comments
 (0)