Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(experiment): Restore of remote backup in different namespace #366

Merged
merged 1 commit into from
May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions experiments/functional/backup_and_restore/backup-restore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
args:
executable: /bin/bash

when: lookup('env','LOCAL_SNAPSHOT') == "false"
when: lookup('env','LOCAL_SNAPSHOT') == "false" and lookup('env','RESTORE_IN_DIFF_NAMESPACE') == "false"

- block:

Expand All @@ -98,7 +98,22 @@
args:
executable: /bin/bash

when: lookup('env','LOCAL_SNAPSHOT') == "true"
when: lookup('env','LOCAL_SNAPSHOT') == "true"

- block:

- name: Creating application namespace
shell: kubectl create ns {{ app_ns_new }}
register: app_ns_create_status
failed_when: "'created' not in app_ns_create_status.stdout"

- name: Restoring application
shell: >
velero restore create --from-backup {{ velero_backup_name }} --restore-volumes=true --namespace-mappings {{ app_ns }}:{{ app_ns_new }}
args:
executable: /bin/bash

when: lookup('env','RESTORE_IN_DIFF_NAMESPACE') == "true"

when: action == "RESTORE"

Expand Down
13 changes: 8 additions & 5 deletions experiments/functional/backup_and_restore/run_litmus_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: batch/v1
kind: Job
metadata:
generateName: litmus-velero-backup-restore
generateName: litmus-velero-backup-restore-
namespace: litmus
spec:
template:
Expand Down Expand Up @@ -50,17 +50,20 @@ spec:
value: "openebs"

- name: VELERO_PLUGIN_NAME
value: "openebs/velero-plugin:ci"
value: "openebs/velero-plugin:1.10.0"

- name: VELERO_VERSION
value: "v1.1.0"
value: "v1.3.0"

#Supported values are {'minio', 'GCP'}
- name: STORAGE_BUCKET
value: "minio"
#Supported values ae {'true', false}, can be set true only with cstor volumes
#Supported values are {'true', false}, can be set true only with cstor volumes
- name: LOCAL_SNAPSHOT
value: "false"
#Supported values are {'true', false}, can be set true only with cstor volumes whose restore will happen in different namespace.
- name: RESTORE_IN_DIFF_NAMESPACE
value: "false"

- name: GCP_PROJECT_ID
value: "openebs-ci"
Expand All @@ -79,4 +82,4 @@ spec:
value: "false"

command: ["/bin/bash"]
args: ["-c", "ansible-playbook ./experiments/functional/backup_and_restore/test.yml -i /etc/ansible/hosts -vv; exit 0"]
args: ["-c", "ansible-playbook ./experiments/functional/backup_and_restore/test.yml -i /etc/ansible/hosts -vv; exit 0"]
26 changes: 19 additions & 7 deletions experiments/functional/backup_and_restore/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,25 @@
when: lookup('env','COMPONENT_FAILURE') != ''

- block:

- block:

- name: Getting the volume name
shell: kubectl get pvc {{ app_pvc }} -n {{ app_ns }} -o jsonpath='{.spec.volumeName}'
register: volume_name

- name: Getting the volume name
shell: kubectl get pvc {{ app_pvc }} -n {{ app_ns }} -o jsonpath='{.spec.volumeName}'
register: volume_name

when: lookup('env','RESTORE_IN_DIFF_NAMESPACE') == "false"

- block:

- name: Getting the volume name
shell: kubectl get pvc {{ app_pvc }} -n {{ app_ns_new }} -o jsonpath='{.spec.volumeName}'
register: volume_name

when: lookup('env','RESTORE_IN_DIFF_NAMESPACE') == "true"

- name: Getting the target IP
shell: kubectl get pod -n {{ operator_ns }} -l openebs.io/persistent-volume={{ volume_name.stdout }} -o jsonpath='{.items[0].status.podIP}'
shell: kubectl get svc -n {{ operator_ns }} --no-headers -l openebs.io/persistent-volume={{ volume_name.stdout }} -o jsonpath='{.items[0].spec.clusterIP}'
register: target_ip
until: 'target_ip.stdout != ""'
delay: 5
Expand Down Expand Up @@ -237,7 +249,7 @@
dbname: "backup"
label: "{{ app_label }}"

when: lookup('env','LOCAL_SNAPSHOT') == "false"
when: lookup('env','LOCAL_SNAPSHOT') == "false" and lookup('env','RESTORE_IN_DIFF_NAMESPACE') == "false"

- block:

Expand All @@ -259,7 +271,7 @@
dbname: "backup"
label: "{{ app_label }}"

when: lookup('env','LOCAL_SNAPSHOT') == "true"
when: lookup('env','LOCAL_SNAPSHOT') == "true" or lookup('env','RESTORE_IN_DIFF_NAMESPACE') == "true"


- set_fact:
Expand Down