From fa32e8467fd774cea13531cd60f37da0d6ae4b28 Mon Sep 17 00:00:00 2001 From: paulfouquet <86932794+paulfouquet@users.noreply.github.com> Date: Fri, 13 Sep 2024 14:53:27 +1200 Subject: [PATCH] feat: add exit handler tasks TDE-1230 (#752) #### Motivation The exit handler logs some useful information about a workflow when it's done. These can be helpful for logging and alerting. #### Modification - call exit-handler task `onExit` #### Checklist - [ ] Tests updated - [ ] Docs updated - [x] Issue linked in Title --- workflows/basemaps/imagery-import-cogify.yml | 16 ++++++++++++++++ workflows/basemaps/vector-etl.yaml | 16 ++++++++++++++++ workflows/cron/cron-stac-validate-fast.yaml | 15 +++++++++++++++ workflows/cron/cron-stac-validate-full.yaml | 15 +++++++++++++++ workflows/raster/copy.yaml | 16 ++++++++++++++++ workflows/raster/publish-odr.yaml | 16 ++++++++++++++++ 6 files changed, 94 insertions(+) diff --git a/workflows/basemaps/imagery-import-cogify.yml b/workflows/basemaps/imagery-import-cogify.yml index aea81323..3969f6ec 100644 --- a/workflows/basemaps/imagery-import-cogify.yml +++ b/workflows/basemaps/imagery-import-cogify.yml @@ -10,6 +10,7 @@ metadata: spec: parallelism: 100 entrypoint: main + onExit: exit-handler synchronization: semaphore: configMapKeyRef: @@ -452,3 +453,18 @@ spec: - '--config-type={{workflow.parameters.config_type}}' - "--individual={{= workflow.parameters.individual == 'individual'? 'true' : 'false' }}" - '--category={{workflow.parameters.category}}' + + - name: exit-handler + retryStrategy: + limit: '0' # `tpl-exit-handler` retries itself + steps: + - - name: exit + templateRef: + name: tpl-exit-handler + template: main + arguments: + parameters: + - name: workflow_status + value: '{{workflow.status}}' + - name: workflow_parameters + value: '{{workflow.parameters}}' diff --git a/workflows/basemaps/vector-etl.yaml b/workflows/basemaps/vector-etl.yaml index eae7879c..b5aa74cf 100644 --- a/workflows/basemaps/vector-etl.yaml +++ b/workflows/basemaps/vector-etl.yaml @@ -9,6 +9,7 @@ metadata: linz.govt.nz/data-type: vector spec: entrypoint: main + onExit: exit-handler podMetadata: labels: linz.govt.nz/category: basemaps @@ -160,3 +161,18 @@ spec: - '--target={{ inputs.parameters.target }}' - '--config-type=vector' - "--individual={{= workflow.parameters.individual == 'individual'? 'true' : 'false' }}" + + - name: exit-handler + retryStrategy: + limit: '0' # `tpl-exit-handler` retries itself + steps: + - - name: exit + templateRef: + name: tpl-exit-handler + template: main + arguments: + parameters: + - name: workflow_status + value: '{{workflow.status}}' + - name: workflow_parameters + value: '{{workflow.parameters}}' diff --git a/workflows/cron/cron-stac-validate-fast.yaml b/workflows/cron/cron-stac-validate-fast.yaml index 02a4cc78..aba57037 100644 --- a/workflows/cron/cron-stac-validate-fast.yaml +++ b/workflows/cron/cron-stac-validate-fast.yaml @@ -15,6 +15,7 @@ spec: suspend: false workflowSpec: entrypoint: main + onExit: exit-handler podMetadata: labels: linz.govt.nz/category: stac @@ -53,3 +54,17 @@ spec: value: '{{workflow.parameters.checksum_assets}}' - name: 'checksum_links' value: '{{workflow.parameters.checksum_links}}' + - name: exit-handler + retryStrategy: + limit: '0' # `tpl-exit-handler` retries itself + steps: + - - name: exit + templateRef: + name: tpl-exit-handler + template: main + arguments: + parameters: + - name: workflow_status + value: '{{workflow.status}}' + - name: workflow_parameters + value: '{{workflow.parameters}}' diff --git a/workflows/cron/cron-stac-validate-full.yaml b/workflows/cron/cron-stac-validate-full.yaml index e3b9d8c0..037cc6bb 100644 --- a/workflows/cron/cron-stac-validate-full.yaml +++ b/workflows/cron/cron-stac-validate-full.yaml @@ -15,6 +15,7 @@ spec: suspend: false workflowSpec: entrypoint: main + onExit: exit-handler podMetadata: labels: linz.govt.nz/category: stac @@ -65,3 +66,17 @@ spec: value: '{{workflow.parameters.checksum_assets}}' - name: 'checksum_links' value: '{{workflow.parameters.checksum_links}}' + - name: exit-handler + retryStrategy: + limit: '0' # `tpl-exit-handler` retries itself + steps: + - - name: exit + templateRef: + name: tpl-exit-handler + template: main + arguments: + parameters: + - name: workflow_status + value: '{{workflow.status}}' + - name: workflow_parameters + value: '{{workflow.parameters}}' diff --git a/workflows/raster/copy.yaml b/workflows/raster/copy.yaml index 14bb4e50..79e7adeb 100644 --- a/workflows/raster/copy.yaml +++ b/workflows/raster/copy.yaml @@ -12,6 +12,7 @@ spec: nodeSelector: karpenter.sh/capacity-type: 'spot' entrypoint: main + onExit: exit-handler synchronization: semaphore: configMapKeyRef: @@ -158,3 +159,18 @@ spec: value: '{{workflow.parameters.aws_role_config_path}}' depends: 'create-manifest' withParam: '{{tasks.create-manifest.outputs.parameters.files}}' + + - name: exit-handler + retryStrategy: + limit: '0' # `tpl-exit-handler` retries itself + steps: + - - name: exit + templateRef: + name: tpl-exit-handler + template: main + arguments: + parameters: + - name: workflow_status + value: '{{workflow.status}}' + - name: workflow_parameters + value: '{{workflow.parameters}}' diff --git a/workflows/raster/publish-odr.yaml b/workflows/raster/publish-odr.yaml index e0a12de9..9ab974b9 100644 --- a/workflows/raster/publish-odr.yaml +++ b/workflows/raster/publish-odr.yaml @@ -12,6 +12,7 @@ spec: nodeSelector: karpenter.sh/capacity-type: 'spot' entrypoint: main + onExit: exit-handler synchronization: semaphore: configMapKeyRef: @@ -126,3 +127,18 @@ spec: - name: copy_option value: '{{inputs.parameters.copy_option}}' depends: 'generate-path' + + - name: exit-handler + retryStrategy: + limit: '0' # `tpl-exit-handler` retries itself + steps: + - - name: exit + templateRef: + name: tpl-exit-handler + template: main + arguments: + parameters: + - name: workflow_status + value: '{{workflow.status}}' + - name: workflow_parameters + value: '{{workflow.parameters}}'