Skip to content

Commit 9cb918e

Browse files
timidriragingraJ-Hunnifordbinford2k
authored
Add backup/restore plans (#339)
First iteration of backup restore, covering use case of restoring degraded PE instance. Migration functionality to be introduced in further release. --------- Co-authored-by: Neil Anderson <[email protected]> Co-authored-by: Neil Anderson <[email protected]> Co-authored-by: JHunniford <[email protected]> Co-authored-by: Dimitri Tischenko <[email protected]> Co-authored-by: Ben Ford <[email protected]>
1 parent d1edf04 commit 9cb918e

31 files changed

+1920
-75
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
---
2+
name: "Backup and restore test"
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
image:
8+
description: "GCP image for test cluster"
9+
required: true
10+
default: "almalinux-cloud/almalinux-8"
11+
architecture:
12+
description: "PE architecture to test"
13+
required: true
14+
default: "standard"
15+
version:
16+
description: "PE version to install"
17+
required: true
18+
default: "2021.7.4"
19+
ssh-debugging:
20+
description: "Boolean; whether or not to pause for ssh debugging"
21+
required: true
22+
default: "false"
23+
24+
jobs:
25+
backup:
26+
name: "Backup: Cluster A: PE ${{ inputs.version }} ${{ inputs.architecture }} on ${{ inputs.image }}"
27+
runs-on: ubuntu-20.04
28+
env:
29+
BOLT_GEM: true
30+
BOLT_DISABLE_ANALYTICS: true
31+
LANG: "en_US.UTF-8"
32+
33+
steps:
34+
- name: "Start SSH session"
35+
if: ${{ github.event.inputs.ssh-debugging == 'true' }}
36+
uses: luchihoratiu/debug-via-ssh@main
37+
with:
38+
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
39+
SSH_PASS: ${{ secrets.SSH_PASS }}
40+
41+
- name: "Checkout Source"
42+
uses: actions/checkout@v2
43+
44+
- name: "Activate Ruby 2.7"
45+
uses: ruby/setup-ruby@v1
46+
with:
47+
ruby-version: "2.7"
48+
bundler-cache: true
49+
50+
- name: "Print bundle environment"
51+
if: ${{ github.repository_owner == 'puppetlabs' }}
52+
run: |
53+
echo ::group::info:bundler
54+
bundle env
55+
echo ::endgroup::
56+
57+
- name: "Provision test cluster"
58+
timeout-minutes: 15
59+
run: |
60+
echo ::group::prepare
61+
mkdir -p $HOME/.ssh
62+
echo 'Host *' > $HOME/.ssh/config
63+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
64+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
65+
bundle exec rake spec_prep
66+
echo ::endgroup::
67+
68+
echo ::group::provision
69+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
70+
--modulepath spec/fixtures/modules \
71+
provider=provision_service \
72+
image=${{ inputs.image }} \
73+
architecture=${{ inputs.architecture }}
74+
echo ::endgroup::
75+
76+
echo ::group::info:request
77+
cat request.json || true; echo
78+
echo ::endgroup::
79+
80+
echo ::group::info:inventory
81+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
82+
echo ::endgroup::
83+
84+
# - name: Save inventory file A to an artifact
85+
# uses: actions/upload-artifact@v3
86+
# with:
87+
# name: inventory_A
88+
# path: spec/fixtures/litmus_inventory.yaml
89+
90+
- name: "Install PE on test cluster"
91+
timeout-minutes: 120
92+
run: |
93+
bundle exec bolt plan run peadm_spec::install_test_cluster \
94+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
95+
--modulepath spec/fixtures/modules \
96+
architecture=${{ inputs.architecture }} \
97+
version=${{ inputs.version }}
98+
99+
- name: "Start SSH session"
100+
if: github.event.inputs.ssh-debugging == 'true'
101+
uses: luchihoratiu/debug-via-ssh@main
102+
with:
103+
NGROK_AUTH_TOKEN: ${{ secrets.NGROK_AUTH_TOKEN }}
104+
SSH_PASS: ${{ secrets.SSH_PASS }}
105+
106+
# - name: Download artifacts
107+
# # if: always()
108+
# uses: actions/download-artifact@v3
109+
# with:
110+
# path: spec/fixtures/
111+
112+
- name: perform PE backup of cluster A
113+
timeout-minutes: 10
114+
continue-on-error: true
115+
run: |
116+
echo ::group::prepare
117+
mkdir -p $HOME/.ssh
118+
echo 'Host *' > $HOME/.ssh/config
119+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
120+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
121+
bundle exec rake spec_prep
122+
echo ::endgroup::
123+
124+
echo ::group::backup
125+
bundle exec bolt plan run peadm_spec::test_backup \
126+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
127+
--modulepath spec/fixtures/modules
128+
echo ::endgroup::
129+
130+
- name: "Wait as long as the file ${HOME}/pause file is present"
131+
continue-on-error: true
132+
# if: ${{ always() && github.event.inputs.ssh-debugging == 'true' }}
133+
if: github.event.inputs.ssh-debugging == 'true'
134+
run: |
135+
while [ -f "${HOME}/pause" ] ; do
136+
echo "${HOME}/pause present, sleeping for 60 seconds..."
137+
sleep 10
138+
done
139+
echo "${HOME}/pause absent, continuing workflow."
140+
141+
- name: "Tear down cluster A"
142+
if: always()
143+
run: |
144+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
145+
echo ::group::tear_down
146+
bundle exec rake 'litmus:tear_down'
147+
echo ::endgroup::
148+
149+
echo ::group::info:request
150+
cat request.json || true; echo
151+
echo ::endgroup::
152+
fi
153+
154+
restore:
155+
name: "Restore: Cluster B: PE ${{ inputs.version }} ${{ inputs.architecture }} on ${{ inputs.image }}"
156+
runs-on: ubuntu-20.04
157+
env:
158+
BOLT_GEM: true
159+
BOLT_DISABLE_ANALYTICS: true
160+
LANG: "en_US.UTF-8"
161+
162+
steps:
163+
- name: "Checkout Source"
164+
uses: actions/checkout@v2
165+
166+
- name: "Activate Ruby 2.7"
167+
uses: ruby/setup-ruby@v1
168+
with:
169+
ruby-version: "2.7"
170+
bundler-cache: true
171+
172+
- name: "Print bundle environment"
173+
if: ${{ github.repository_owner == 'puppetlabs' }}
174+
run: |
175+
echo ::group::info:bundler
176+
bundle env
177+
echo ::endgroup::
178+
179+
- name: "Provision test cluster"
180+
timeout-minutes: 15
181+
run: |
182+
echo ::group::prepare
183+
mkdir -p $HOME/.ssh
184+
echo 'Host *' > $HOME/.ssh/config
185+
echo ' ServerAliveInterval 150' >> $HOME/.ssh/config
186+
echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config
187+
bundle exec rake spec_prep
188+
echo ::endgroup::
189+
190+
echo ::group::provision
191+
bundle exec bolt plan run peadm_spec::provision_test_cluster \
192+
--modulepath spec/fixtures/modules \
193+
provider=provision_service \
194+
image=${{ inputs.image }} \
195+
architecture=${{ inputs.architecture }}
196+
echo ::endgroup::
197+
198+
echo ::group::info:request
199+
cat request.json || true; echo
200+
echo ::endgroup::
201+
202+
echo ::group::info:inventory
203+
sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true
204+
echo ::endgroup::
205+
206+
# - name: Save inventory file B to an artifact
207+
# uses: actions/upload-artifact@v3
208+
# with:
209+
# name: inventory_B
210+
# path: spec/fixtures/litmus_inventory.yaml
211+
212+
- name: "Install PE on test cluster"
213+
timeout-minutes: 120
214+
run: |
215+
bundle exec bolt plan run peadm_spec::install_test_cluster \
216+
--inventoryfile spec/fixtures/litmus_inventory.yaml \
217+
--modulepath spec/fixtures/modules \
218+
architecture=${{ inputs.architecture }} \
219+
version=${{ inputs.version }}
220+
221+
- name: Wait for backup to finish
222+
uses: lewagon/[email protected]
223+
with:
224+
ref: ${{ github.ref }}
225+
check-name: "Backup: Cluster A: PE ${{ inputs.version }} ${{ inputs.architecture }} on ${{ inputs.image }}"
226+
repo-token: ${{ secrets.GITHUB_TOKEN }}
227+
wait-interval: 10
228+
229+
- name: "Tear down cluster B"
230+
if: always()
231+
run: |
232+
cp spec/fixtures/inventory_B/litmus_inventory.yaml spec/fixtures/litmus_inventory.yaml || true
233+
if [ -f spec/fixtures/litmus_inventory.yaml ]; then
234+
echo ::group::tear_down
235+
bundle exec rake 'litmus:tear_down'
236+
echo ::endgroup::
237+
238+
echo ::group::info:request
239+
cat request.json || true; echo
240+
echo ::endgroup::
241+
fi

0 commit comments

Comments
 (0)