Skip to content

Commit

Permalink
move template to templates folder, add helper script
Browse files Browse the repository at this point in the history
  • Loading branch information
conbrad committed Nov 5, 2024
1 parent 6164b76 commit 728d53f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 11 deletions.
34 changes: 34 additions & 0 deletions openshift/scripts/oc_provision_fill_partition_job.sh
Original file line number Diff line number Diff line change
@@ -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}

Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 728d53f

Please sign in to comment.