From e9398c9fa4878ecc8eada184cf0f7fb175cf33de Mon Sep 17 00:00:00 2001 From: Aiden Keating Date: Tue, 12 Mar 2019 11:02:02 +0000 Subject: [PATCH] INTLY-1100 Add monitoring label and concurrency policy Allow the concurrency policy to be overridden and default the value to Forbid. The reasoning for this is to prevent multiple occurrences of the same Job to run at the same time. Add monitoring labels to the CronJob and the Jobs that it creates so that monitoring alerts can reference that when referring to all Integreatly CronJobs instead of just having a static list. Verification: - Modify the cron schedule in the CronJob template to be something like `*/1 * * * *`, to run once per minute. - Do an `oc create` on the template. - Ensure that the created CronJob has the `concurrencyPolicy` of `Forbid`. - Ensure that the created CronJob has a label with the name `monitoring-key` and the value `middleware`. - Ensure that a Job created by the CronJob has a label with the name `monitoring-key` and the value `middleware`. --- templates/openshift/backup-cronjob-template.yaml | 7 +++++++ templates/openshift/backup-job-template.yaml | 2 ++ 2 files changed, 9 insertions(+) diff --git a/templates/openshift/backup-cronjob-template.yaml b/templates/openshift/backup-cronjob-template.yaml index 041703c..10e5882 100644 --- a/templates/openshift/backup-cronjob-template.yaml +++ b/templates/openshift/backup-cronjob-template.yaml @@ -10,14 +10,18 @@ objects: kind: CronJob metadata: name: ${NAME} + labels: + monitoring-key: middleware spec: schedule: ${CRON_SCHEDULE} + concurrencyPolicy: ${CONCURRENCY_POLICY} jobTemplate: spec: template: metadata: name: ${NAME} labels: + monitoring-key: middleware cronjob-name: ${NAME} spec: serviceAccountName: "${SERVICEACCOUNT}" @@ -83,3 +87,6 @@ parameters: value: backupjob - name: DEBUG description: "Debug flag to sleep the job pod after its execution" + - name: CONCURRENCY_POLICY + description: The concurrency policy of the CronJob + value: Forbid diff --git a/templates/openshift/backup-job-template.yaml b/templates/openshift/backup-job-template.yaml index f28fcbe..aa93528 100644 --- a/templates/openshift/backup-job-template.yaml +++ b/templates/openshift/backup-job-template.yaml @@ -10,6 +10,8 @@ objects: kind: Job metadata: name: ${NAME} + labels: + monitoring-key: middleware spec: parallelism: 1 completions: 1