Skip to content

Commit

Permalink
Merge pull request #202 from dsavineau/ci_backup_restore
Browse files Browse the repository at this point in the history
ci: Add backup and restore
  • Loading branch information
dsavineau authored May 15, 2024
2 parents b6f0d71 + 49ba951 commit e604753
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .ci/eda_v1alpha1_eda.default.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ metadata:
"ansible.sdk.operatorframework.io/verbosity": "5"
spec:
no_log: false
automation_server_url: https://foo.bar
automation_server_url: http://foo.bar
2 changes: 1 addition & 1 deletion .ci/eda_v1alpha1_eda.ingress.ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ metadata:
"ansible.sdk.operatorframework.io/verbosity": "5"
spec:
no_log: false
automation_server_url: https://foo.bar
automation_server_url: http://foo.bar
ingress_type: ingress
9 changes: 9 additions & 0 deletions .ci/eda_v1alpha1_edabackup.ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: eda.ansible.com/v1alpha1
kind: EDABackup
metadata:
name: eda-demo-backup
annotations:
"ansible.sdk.operatorframework.io/verbosity": "5"
spec:
no_log: false
deployment_name: eda-demo
10 changes: 10 additions & 0 deletions .ci/eda_v1alpha1_edarestore.ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: eda.ansible.com/v1alpha1
kind: EDARestore
metadata:
name: eda-demo-restore
annotations:
"ansible.sdk.operatorframework.io/verbosity": "5"
spec:
no_log: false
deployment_name: eda-demo
backup_name: eda-demo-backup
39 changes: 25 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
jobs:
eda:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -43,12 +43,10 @@ jobs:
env:
VERSION: main

- name: Set imagePullPolicy to ifNotPresent
- name: Deploy the EDA operator
run: |
sed -i 's/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g' config/manager/manager.yaml
- name: Deploy the EDA operator
run: make deploy
make deploy
env:
NAMESPACE: eda
VERSION: main
Expand All @@ -61,13 +59,10 @@ jobs:
if: ${{ matrix.SCENARIO == 'externaldb' }}

- name: Create the EDA demo CR
run: kubectl apply -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml

- name: Print EDA demo CR
run: kubectl -n eda get eda eda-demo -o yaml

- name: Check and wait the EDA demo to be ready
run: kubectl wait --for condition=Successful eda/eda-demo --timeout=-1s
run: |
kubectl apply -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
kubectl -n eda get eda eda-demo -o yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
- name: Test EDA API via k8s service
run: |
Expand All @@ -82,11 +77,27 @@ jobs:
curl -s http://${IP}:80/api/eda/v1/status/
if: ${{ matrix.SCENARIO == 'ingress' }}

- name: Backup EDA demo
run: |
kubectl apply -f .ci/eda_v1alpha1_edabackup.ci.yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_edabackup.ci.yaml
- name: Delete the EDA demo CR
run: |
kubectl delete --cascade=foreground -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
kubectl wait --for=delete --timeout=-1s -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
- name: Restore EDA demo
run: |
kubectl apply -f .ci/eda_v1alpha1_edarestore.ci.yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_edarestore.ci.yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
- name: Get logs
if: always()
run: |
echo ::group::OPERATOR_LOGS
kubectl logs -l control-plane=controller-manager --tail=1000 || true
kubectl logs -l control-plane=controller-manager --tail=10000 || true
echo ::endgroup::
echo ::group::POSTGRES_LOGS
kubectl logs -l app.kubernetes.io/component=database --tail=1000 || true
Expand All @@ -103,7 +114,7 @@ jobs:
echo ::group::EDA_DEFAULT_WORKER_LOGS
kubectl logs -l app.kubernetes.io/component=eda-default-worker --tail=1000 || true
echo ::endgroup::
echo ::group::EDA_ACTIVATION_WORKERLOGS
echo ::group::EDA_ACTIVATION_WORKER_LOGS
kubectl logs -l app.kubernetes.io/component=eda-activation-worker --tail=1000 || true
echo ::endgroup::
echo ::group::EDA_SCHEDULER_LOGS
Expand Down
39 changes: 25 additions & 14 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
jobs:
eda:
runs-on: ubuntu-latest
timeout-minutes: 10
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -41,12 +41,10 @@ jobs:
env:
VERSION: main

- name: Set imagePullPolicy to ifNotPresent
- name: Deploy the EDA operator
run: |
sed -i 's/imagePullPolicy: Always/imagePullPolicy: IfNotPresent/g' config/manager/manager.yaml
- name: Deploy the EDA operator
run: make deploy
make deploy
env:
NAMESPACE: eda
VERSION: main
Expand All @@ -59,13 +57,10 @@ jobs:
if: ${{ matrix.SCENARIO == 'externaldb' }}

- name: Create the EDA demo CR
run: kubectl apply -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml

- name: Print EDA demo CR
run: kubectl -n eda get eda eda-demo -o yaml

- name: Check and wait the EDA demo to be ready
run: kubectl wait --for condition=Successful eda/eda-demo --timeout=-1s
run: |
kubectl apply -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
kubectl -n eda get eda eda-demo -o yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
- name: Test EDA API via k8s service
run: |
Expand All @@ -80,11 +75,27 @@ jobs:
curl -s http://${IP}:80/api/eda/v1/status/
if: ${{ matrix.SCENARIO == 'ingress' }}

- name: Backup EDA demo
run: |
kubectl apply -f .ci/eda_v1alpha1_edabackup.ci.yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_edabackup.ci.yaml
- name: Delete the EDA demo CR
run: |
kubectl delete --cascade=foreground -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
kubectl wait --for=delete --timeout=-1s -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
- name: Restore EDA demo
run: |
kubectl apply -f .ci/eda_v1alpha1_edarestore.ci.yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_edarestore.ci.yaml
kubectl wait --for condition=Successful --timeout=-1s -f .ci/eda_v1alpha1_eda.${{ matrix.SCENARIO }}.ci.yaml
- name: Get logs
if: always()
run: |
echo ::group::OPERATOR_LOGS
kubectl logs -l control-plane=controller-manager --tail=1000 || true
kubectl logs -l control-plane=controller-manager --tail=10000 || true
echo ::endgroup::
echo ::group::POSTGRES_LOGS
kubectl logs -l app.kubernetes.io/component=database --tail=1000 || true
Expand All @@ -101,7 +112,7 @@ jobs:
echo ::group::EDA_DEFAULT_WORKER_LOGS
kubectl logs -l app.kubernetes.io/component=eda-default-worker --tail=1000 || true
echo ::endgroup::
echo ::group::EDA_ACTIVATION_WORKERLOGS
echo ::group::EDA_ACTIVATION_WORKER_LOGS
kubectl logs -l app.kubernetes.io/component=eda-activation-worker --tail=1000 || true
echo ::endgroup::
echo ::group::EDA_SCHEDULER_LOGS
Expand Down
3 changes: 1 addition & 2 deletions roles/restore/tasks/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@

- name: Set full resolvable host name for postgres pod
set_fact:
resolvable_db_host: "{{ eda_postgres_host }}.{{ ansible_operator_meta.namespace }}.svc.{{ cluster_name }}"
resolvable_db_host: "{{ (eda_postgres_type == 'managed') | ternary(eda_postgres_host + '.' + ansible_operator_meta.namespace + '.svc.' + cluster_name, eda_postgres_host) }}"
no_log: "{{ no_log }}"
when: eda_postgres_type == 'managed'

- name: Set pg_restore command
set_fact:
Expand Down

0 comments on commit e604753

Please sign in to comment.