Skip to content

Commit

Permalink
feat: added env variable for cronjob schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
MacQSL committed Nov 18, 2024
1 parent d119cff commit c20bd64
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
7 changes: 7 additions & 0 deletions api/.pipeline/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ const deployChangeId = (isStaticDeployment && 'deploy') || changeId;
const branch = (isStaticDeployment && options.branch) || null;
const tag = (branch && `build-${version}-${changeId}-${branch}`) || `build-${version}-${changeId}`;

// The telemetry cronjob schedule - dev/test/prod runs at midnight, PR's NEVER run
const telemetryCronjobSchedule = (isStaticDeployment && '0 0 * * *') || '0 0 0 * *';

const staticUrlsAPI = config.staticUrlsAPI;
const staticUrls = config.staticUrls;

Expand Down Expand Up @@ -71,6 +74,7 @@ const phases = {
dbName: `${dbName}`,
phase: 'dev',
changeId: deployChangeId,
telemetryCronjobSchedule: telemetryCronjobSchedule,
suffix: `-dev-${deployChangeId}`,
instance: `${name}-dev-${deployChangeId}`,
version: `${deployChangeId}-${changeId}`,
Expand Down Expand Up @@ -114,6 +118,7 @@ const phases = {
dbName: `${dbName}`,
phase: 'test',
changeId: deployChangeId,
telemetryCronjobSchedule: telemetryCronjobSchedule,
suffix: `-test`,
instance: `${name}-test`,
version: `${version}`,
Expand Down Expand Up @@ -157,6 +162,7 @@ const phases = {
dbName: `${dbName}-spi`,
phase: 'test-spi',
changeId: deployChangeId,
telemetryCronjobSchedule: telemetryCronjobSchedule,
suffix: `-test-spi`,
instance: `${name}-spi-test-spi`,
version: `${version}`,
Expand Down Expand Up @@ -200,6 +206,7 @@ const phases = {
dbName: `${dbName}`,
phase: 'prod',
changeId: deployChangeId,
telemetryCronjobSchedule: telemetryCronjobSchedule,
suffix: `-prod`,
instance: `${name}-prod`,
version: `${version}`,
Expand Down
2 changes: 2 additions & 0 deletions api/.pipeline/lib/api.deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const apiDeploy = async (settings) => {
HOST: phases[phase].host,
APP_HOST: phases[phase].appHost,
CHANGE_ID: phases.build.changeId || changeId,
// Cronjobs
TELEMETRY_CRONJOB_SCHEDULE: phases[phase].telemetryCronjobSchedule,
// Node
NODE_ENV: phases[phase].nodeEnv,
NODE_OPTIONS: phases[phase].nodeOptions,
Expand Down
18 changes: 10 additions & 8 deletions api/.pipeline/templates/api.dc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ parameters:
- name: CHANGE_ID
description: Change id of the project. This will help to pull image stream
required: true
- name: CRONJOB_SCHEDULE
description: The
required: true
value: '0'
- name: NODE_ENV
description: Application Environment type variable
Expand Down Expand Up @@ -206,6 +209,9 @@ parameters:
- name: REPLICAS_MAX
value: '1'
# Telemetry
- name: TELEMETRY_CRONJOB_SCHEDULE
description: The schedule for the telemetry cronjob
value: '0 0 0 * *' # This will never run - see `config.js` - Phase injects valid schedules for static deployments only
- name: TELEMETRY_SECRET
description: The name of the Openshift Biohubbc telemetry secret
value: biohubbc-telemetry
Expand Down Expand Up @@ -564,8 +570,8 @@ objects:
labels:
role: telemetry-cronjob
spec:
schedule: '0 0 * * *' # Runs every day at 12:00am
concurrencyPolicy: "Replace"
schedule: ${TELEMETRY_CRONJOB_SCHEDULE}
concurrencyPolicy: "Forbid"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 1
jobTemplate:
Expand All @@ -577,10 +583,6 @@ objects:
image: ${BASE_IMAGE_REGISTRY_URL}/${NAMESPACE}/${NAME}:${VERSION}
imagePullPolicy: Always
env:
- name: VERSION
value: ${VERSION}
- name: CHANGE_VERSION
value: ${CHANGE_ID}
- name: NODE_ENV
value: ${NODE_ENV}
- name: NODE_OPTIONS
Expand Down Expand Up @@ -627,10 +629,10 @@ objects:
value: ${LOG_LEVEL}
- name: LOG_LEVEL_FILE
value: ${LOG_LEVEL_FILE}
- name: LOG_FILE_DIR
- name: data/cronjob-logs
value: ${LOG_FILE_DIR}
- name: LOG_FILE_NAME
value: ${LOG_FILE_NAME}
value: sims-telemetry-cronjob-%DATE%.log
- name: LOG_FILE_DATE_PATTERN
value: ${LOG_FILE_DATE_PATTERN}
- name: LOG_FILE_MAX_SIZE
Expand Down
8 changes: 8 additions & 0 deletions api/.pipeline/templates/prereqs/biohubbc-telemetry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
kind: Secret
apiVersion: v1
metadata:
name: biohubbc-telemetry
data:
lotek_acount_username: <fill in values>
lotek_acount_password: <fill in values>
type: Opaque

0 comments on commit c20bd64

Please sign in to comment.