Skip to content

Commit

Permalink
chore: Add the preprod refresh versions script (#2449)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimbali authored Dec 18, 2024
1 parent a5e0643 commit 1098e37
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 730 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "create-temp-tables" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "copy-from-temp-sql" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "drop-temp-tables" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-script" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $fullName }}
data:
entrypoint.sh: |-
#!/bin/bash
from=$(date --date="2 days ago" '+%Y-%m-%d')
to=$(date '+%Y-%m-%d')
from=$(date --date="{{ .Values.scripts.preprodRefresh.main.dataSince }}" '+%Y-%m-%d %T')
to=$(date '+%Y-%m-%d %T')
echo "Refreshing data from ${from} to ${to}"
createTemp='/tmp/sql/createTables.sql'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
{{- $script2 := printf "%s-%s" (include "generic-service.fullname" $) "copy-from-temp-sql" | trunc 52 }}
{{- $script3 := printf "%s-%s" (include "generic-service.fullname" $) "drop-temp-tables" | trunc 52 }}
{{- $script4 := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-script" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.enabled }}
{{- if .Values.scripts.preprodRefresh.main.enabled }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ $fullName }}
spec:
schedule: {{ .Values.scripts.preprodRefresh.schedule }}
schedule: {{ .Values.scripts.preprodRefresh.main.schedule }}
concurrencyPolicy: "Forbid"
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 3
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-versions-script" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.versions.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: preprod-refresh-versions-script
name: {{ $fullName }}
data:
entrypoint.sh: |-
#!/bin/bash
from=$(date --date="26 hours ago" '+%Y-%m-%d %T')
from=$(date --date="{{ .Values.scripts.preprodRefresh.versions.dataSince }}" '+%Y-%m-%d %T')
to=$(date '+%Y-%m-%d %T')
echo "Refreshing versions from ${from} to ${to}"
Expand Down Expand Up @@ -38,4 +40,5 @@ data:
echo "Dropping temporary tables"
execDest "DROP TABLE IF EXISTS versions_temp CASCADE;"
execSource "DROP TABLE IF EXISTS versions_temp CASCADE;"
echo "All done!"
echo "All done!"
{{- end }}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{{- $genericService := index .Values "generic-service" -}}
{{- $fullName := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh" | trunc 52 }}
{{- $script1 := printf "%s-%s" (include "generic-service.fullname" $) "preprod-refresh-versions-script" | trunc 52 }}
{{- if .Values.scripts.preprodRefresh.versions.enabled }}
---
apiVersion: batch/v1
kind: CronJob
metadata:
name: preprod-refresh-versions-job
spec:
schedule: "15 7 * * *"
schedule: {{ .Values.scripts.preprodRefresh.versions.schedule }}
concurrencyPolicy: "Forbid"
successfulJobsHistoryLimit: 5
failedJobsHistoryLimit: 3
Expand Down Expand Up @@ -43,5 +47,6 @@ spec:
volumes:
- name: preprod-refresh-versions-script
configMap:
name: preprod-refresh-versions-script
defaultMode: 0755
name: {{ $script1 }}
defaultMode: 0755
{{- end }}
10 changes: 8 additions & 2 deletions helm_deploy/hmpps-book-secure-move-api/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,14 @@ dashboards:

scripts:
preprodRefresh:
enabled: false
# schedule: "15 6 * * *"
main:
enabled: false
# schedule: "0 */4 * * *"
# dataSince: "6 hours ago"
versions:
enabled: false
# schedule: "15 7 * * *"
# dataSince: "26 hours ago"
reports:
enabled: false
dailyIpt:
Expand Down
10 changes: 8 additions & 2 deletions helm_deploy/values-production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,14 @@ dashboards:

scripts:
preprodRefresh:
enabled: true
schedule: "15 6 * * *"
main:
enabled: true
schedule: "0 */4 * * *"
dataSince: "6 hours ago"
versions:
enabled: true
schedule: "15 7 * * *"
dataSince: "26 hours ago"
reports:
enabled: true
dailyIpt:
Expand Down
43 changes: 0 additions & 43 deletions preprod-refresh/01-create-temp-tables-sql.yaml

This file was deleted.

Loading

0 comments on commit 1098e37

Please sign in to comment.