-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (108 loc) · 3.59 KB
/
migrate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: "Migrate"
on:
push:
branches: [2.9, 3.1, 3.2, 3.3, main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths:
- '**.go'
- 'go.mod'
- 'snap/**'
- '.github/workflows/migrate.yml'
- 'scripts/dqlite/**'
- 'Makefile'
- 'make_functions.sh'
workflow_dispatch:
permissions:
contents: read
jobs:
migrate:
name: 3.1-to-4.x via ${{ matrix.client }} client
runs-on: [self-hosted, linux, arm64, aws, large]
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
# TODO: add microk8s tests
cloud: ["lxd"]
channel: ["3.1/stable"]
client: ['3.1', '4.x']
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'go.mod'
cache: true
- name: Set up Go env
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Setup LXD
if: matrix.cloud == 'lxd'
uses: canonical/[email protected]
- name: Install Juju 3.1
run: |
sudo snap install juju --channel ${{ matrix.channel }}
mkdir -p ~/.local/share/juju
- name: Bootstrap a 3.1 controller and model
run: |
/snap/bin/juju version
/snap/bin/juju bootstrap lxd test31 --constraints "arch=$(go env GOARCH)"
/snap/bin/juju add-model test-migrate
/snap/bin/juju set-model-constraints arch=$(go env GOARCH)
/snap/bin/juju deploy ubuntu
# TODO: use juju-restore
# TODO: add users/permissions/models and test that those migrate over
- name: Upgrade client to 4.x
run: |
make juju jujud &>/dev/null
- name: Bootstrap 4.x controller
run: |
juju version
juju bootstrap lxd test4x --constraints "arch=$(go env GOARCH)"
juju switch controller
juju wait-for application controller
# TODO: create backup and juju restore
- name: Migrate default model to 4.x controller
run: |
# Determine which Juju client to use
JUJU='juju'
if [[ ${{ matrix.client }} == '3.1' ]]; then
JUJU='/snap/bin/juju'
fi
$JUJU switch test31
# Ensure application is fully deployed
# We have to use the old client to speak to the new controller, as
# this is blocked otherwise.
/snap/bin/juju wait-for application ubuntu
# Wait a few secs for the machine status to update
# so that migration prechecks pass.
sleep 10
$JUJU version
$JUJU migrate test-migrate test4x
- name: Check the migration was successful
run: |
set -x
juju switch test4x
juju status -m test4x/test-migrate
# Wait for 'test-migrate' model to come through
attempt=0
while true; do
RES=$(juju models | grep 'test-migrate' || true)
if [[ -n $RES ]]; then
break
fi
juju status
sleep 5
attempt=$((attempt+1))
if [ "$attempt" -eq 10 ]; then
echo "Migration timed out"
exit 1
fi
done
juju switch test-migrate
juju wait-for application ubuntu
juju deploy ubuntu yet-another-ubuntu
juju wait-for application yet-another-ubuntu