Skip to content

Commit a351755

Browse files
Merge pull request opendatahub-io#61 from DharmitD/mysql-dump
feat(backend): Adding a cron job for MariaDB backup
2 parents b6ef353 + 08769d3 commit a351755

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: batch/v1
2+
kind: CronJob
3+
metadata:
4+
labels:
5+
application-crd-id: data-science-pipelines
6+
name: mariadb-backup
7+
spec:
8+
schedule: "0 0 * * *"
9+
concurrencyPolicy: "Replace"
10+
startingDeadlineSeconds: 200
11+
suspend: false
12+
successfulJobsHistoryLimit: 3
13+
failedJobsHistoryLimit: 1
14+
jobTemplate:
15+
spec:
16+
template:
17+
metadata:
18+
labels:
19+
parent: "mariadb-backup"
20+
spec:
21+
containers:
22+
- name: mariadb-backup
23+
image: mysql
24+
command:
25+
- /bin/sh
26+
- '-c'
27+
- >
28+
mysqldump -h mysql -u $MYSQL_USER --password=$MYSQL_PASSWORD
29+
--all-databases > mariadb-backup.sql
30+
env:
31+
- name: MYSQL_USER
32+
valueFrom:
33+
secretKeyRef:
34+
name: $(database_secret)
35+
key: username
36+
- name: MYSQL_PASSWORD
37+
valueFrom:
38+
secretKeyRef:
39+
name: $(database_secret)
40+
key: password
41+
- name: MYSQL_DATABASE
42+
valueFrom:
43+
configMapKeyRef:
44+
key: pipelineDb
45+
name: $(pipeline_install_configuration)
46+
- name: MYSQL_ALLOW_EMPTY_PASSWORD
47+
value: "true"
48+
serviceAccountName: mysql
49+
restartPolicy: Never

manifests/opendatahub/overlays/metadata-store-mariadb/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@ resources:
1818
# Services
1919
- ./services/mysql.yaml
2020

21+
# CronJobs
22+
- ./cronjobs/mariadb-backup.yaml
23+
2124
generatorOptions:
2225
disableNameSuffixHash: true
2326

27+
configurations:
28+
- params.yaml
29+
2430
images:
2531
- name: mysql
2632
newName: registry.redhat.io/rhel8/mariadb-103
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
varReference:
3+
- path: spec/jobTemplate/spec/template/spec/containers[]/env[]/valueFrom/secretKeyRef/name
4+
kind: CronJob
5+
- path: spec/jobTemplate/spec/template/spec/containers[]/env[]/valueFrom/configMapKeyRef/name
6+
kind: CronJob

tests/basictests/ds-pipelines.sh

100644100755
Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,18 @@ os::test::junit::declare_suite_start "$MY_SCRIPT"
1212
function check_resources() {
1313
header "Testing Data Science Pipelines installation"
1414
os::cmd::expect_success "oc project ${ODHPROJECT}"
15-
os::cmd::try_until_text "oc get crd pipelineruns.tekton.dev " "pipelineruns.tekton.dev" $odhdefaulttimeout $odhdefaultinterval
15+
os::cmd::try_until_text "oc get crd pipelineruns.tekton.dev" "pipelineruns.tekton.dev" $odhdefaulttimeout $odhdefaultinterval
1616
os::cmd::try_until_text "oc get pods -l application-crd-id=data-science-pipelines --field-selector='status.phase!=Running,status.phase!=Completed' -o jsonpath='{$.items[*].metadata.name}' | wc -w" "0" $odhdefaulttimeout $odhdefaultinterval
1717
running_pods=$(oc get pods -l application-crd-id=data-science-pipelines --field-selector='status.phase=Running' -o jsonpath='{$.items[*].metadata.name}' | wc -w)
1818
os::cmd::expect_success "if [ "$running_pods" -gt "0" ]; then exit 0; else exit 1; fi"
1919
}
2020

21+
function check_mariadb_backup() {
22+
header "Check if MariaDB backup comes up correctly"
23+
os::cmd::expect_success "oc get cronjob mariadb-backup"
24+
os::cmd::expect_success "oc create job --from=cronjob/mariadb-backup mariadb-backup"
25+
}
26+
2127
function check_ui_overlay() {
2228
header "Checking UI overlay Kfdef deploys the UI"
2329
os::cmd::try_until_text "oc get pods -l app=ds-pipeline-ui --field-selector='status.phase=Running' -o jsonpath='{$.items[*].metadata.name}' | wc -w" "1" $odhdefaulttimeout $odhdefaultinterval
@@ -85,6 +91,7 @@ function delete_pipeline() {
8591
}
8692

8793
check_resources
94+
check_mariadb_backup
8895
check_ui_overlay
8996
create_pipeline
9097
list_pipelines

0 commit comments

Comments
 (0)