From 728d53f68e29b8065100d4b7542f794ec67411d6 Mon Sep 17 00:00:00 2001 From: Conor Brady Date: Tue, 5 Nov 2024 13:53:13 -0800 Subject: [PATCH] move template to templates folder, add helper script --- .../oc_provision_fill_partition_job.sh | 34 +++++++++++++++++++ .../partition_filler_job.yaml | 17 ++++------ 2 files changed, 40 insertions(+), 11 deletions(-) create mode 100755 openshift/scripts/oc_provision_fill_partition_job.sh rename openshift/{pgslice/openshift => templates}/partition_filler_job.yaml (83%) diff --git a/openshift/scripts/oc_provision_fill_partition_job.sh b/openshift/scripts/oc_provision_fill_partition_job.sh new file mode 100755 index 000000000..ea54cdea9 --- /dev/null +++ b/openshift/scripts/oc_provision_fill_partition_job.sh @@ -0,0 +1,34 @@ +#!/bin/sh -l +# +source "$(dirname ${0})/common/common" + +#% +#% OpenShift Deploy Helper +#% +#% Intended for use with a pull request-based pipeline. +#% Suffixes incl.: pr-###. +#% +#% Usage: +#% +#% [PROJ_TARGET] [PG_DATABASE] [TABLE] ${THIS_FILE} [SUFFIX] +#% +#% Examples: +#% +#% PROJ_TARGET=e1e498-dev PG_DATABASE=wps TABLE=table ${THIS_FILE} pr-0 + +JOB="job/fill-partition-data-${SUFFIX}" + +# create the job +oc -n ${PROJ_TARGET} process -f ${TEMPLATE_PATH}/partition_filler_job.yaml \ + -p SUFFIX=${SUFFIX} \ + -p PG_DATABASE=${PG_DATABASE} \ + -p TABLE=${TABLE} \ + -p CRUNCHYDB_USER=wps-crunchydb-${SUFFIX}-pguser-wps-crunchydb-${SUFFIX} \ + -p PROJ_TOOLS=${PROJ_TOOLS} | jq '.items[0]' | oc -n ${PROJ_TARGET} create -f - +# wait for the job to finish +oc wait --for=condition=complete ${JOB} --timeout=60s +# output the log for debugging +oc logs -f ${JOB} +# we're done, so get rid of the job +oc delete ${JOB} + diff --git a/openshift/pgslice/openshift/partition_filler_job.yaml b/openshift/templates/partition_filler_job.yaml similarity index 83% rename from openshift/pgslice/openshift/partition_filler_job.yaml rename to openshift/templates/partition_filler_job.yaml index d6dad5bab..0f335207e 100644 --- a/openshift/pgslice/openshift/partition_filler_job.yaml +++ b/openshift/templates/partition_filler_job.yaml @@ -33,24 +33,19 @@ parameters: description: "The table that is partitioned" required: true value: "prod" - - name: APP_LABEL - required: true objects: - kind: Job apiVersion: batch/v1 metadata: name: partition-filler-${NAME}-${SUFFIX} spec: - # We use the "Replace" policy, because we never want the cronjobs to run concurrently, - # and if for whatever reason a cronjob gets stuck, we want the next run to proceed. - # If we were to use Forbid, and a cronjob gets stuck, then we'd stop gathering data until someone - # noticed. We don't want that. - concurrencyPolicy: "Replace" - jobTemplate: + parallelism: 1 + completions: 1 + activeDeadlineSeconds: 3600 + backoffLimit: 6 + template: metadata: - labels: - cronjob: partition-filler-${NAME}-${SUFFIX} - app: ${APP_LABEL} + name: partition-filler-${NAME}-${SUFFIX} spec: template: spec: