Skip to content

Merge pull request #17717 from hpidcock/merge-3.6-main-20240711 #574

Merge pull request #17717 from hpidcock/merge-3.6-main-20240711

Merge pull request #17717 from hpidcock/merge-3.6-main-20240711 #574

Workflow file for this run

name: "Migrate"
on:
push:
branches: [2.*, 3.*, 4.*, main]
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
permissions:
contents: read
jobs:
migrate:
name: migrate from ${{ matrix.channel }} client
timeout-minutes: 30
runs-on: [self-hosted, linux, arm64, aws, xlarge]
if: github.event.pull_request.draft == false
strategy:
fail-fast: false
matrix:
# TODO: add microk8s tests
cloud: ["lxd"]
channel: ["local", "3.6/edge"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
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/setup-lxd@4e959f8e0d9c5feb27d44c5e4d9a330a782edee0
- name: Wait for LXD
if: matrix.cloud == 'lxd'
run: |
while ! ip link show lxdbr0; do
echo "Waiting for lxdbr0..."
sleep 10
done
- name: Build local juju client
run: |
BUILD_TAGS='minimal provider_lxd' make juju jujud jujud-controller
- name: Install Juju ${{ matrix.channel }}
if: ${{ matrix.channel != 'local' }}
run: |
mkdir -p ~/.local/share/juju
sudo snap install juju --channel ${{ matrix.channel }}
- name: Bootstrap a ${{ matrix.channel }} source controller and model
if: ${{ matrix.channel != 'local' }}
run: |
/snap/bin/juju version
/snap/bin/juju bootstrap lxd source-controller --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
- name: Bootstrap a ${{ matrix.channel }} source controller and model
if: matrix.channel == 'local'
run: |
juju version
juju bootstrap lxd source-controller --constraints "arch=$(go env GOARCH)"
juju add-model test-migrate
juju set-model-constraints arch=$(go env GOARCH)
juju deploy ubuntu
- name: Bootstrap target controller
run: |
juju version
juju bootstrap lxd target-controller \
--constraints "arch=$(go env GOARCH)" \
--model-default enable-os-upgrade=false
juju switch controller
attempt=0
until [[ $(juju status controller) ]]; do
echo "controller not found, waiting..."
juju status controller
if [[ ${attempt} -eq 10 ]]; then
exit 1
fi
sleep 1;
attempt=$((attempt+1))
done
- name: Determine which Juju client to use
shell: bash
run: |
JUJU_CLIENT='juju'
if [[ ${{ matrix.channel }} != 'local' ]]; then
JUJU_CLIENT='/snap/bin/juju'
fi
echo "JUJU_CLIENT=$JUJU_CLIENT" >> $GITHUB_ENV
- name: Wait for everything to reach a steady state
shell: bash
run: |
export JUJU_CLIENT
# Wait for source machine to start
MODEL='source-controller:test-migrate' \
QUERY='.machines."0"."juju-status".current' EXPECTED='started' \
MAX_ATTEMPTS=60 ./.github/waitfor.sh
# Wait for unit ubuntu/0 to reach idle state
MODEL='source-controller:test-migrate' \
QUERY='.applications.ubuntu.units."ubuntu/0"."juju-status".current' \
EXPECTED='idle' ./.github/waitfor.sh
# Wait for target controller machine to start
MODEL='target-controller:controller' \
QUERY='.machines."0"."machine-status".current' \
EXPECTED='running' ./.github/waitfor.sh
- name: Migrate model to target controller
shell: bash
run: |
$JUJU_CLIENT switch source-controller
$JUJU_CLIENT version
$JUJU_CLIENT status -m source-controller:test-migrate --format json || true
$JUJU_CLIENT migrate test-migrate target-controller
- name: Check the migration was successful
run: |
set -x
juju switch target-controller
# 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 -m target-controller:test-migrate || true
sleep 5
attempt=$((attempt+1))
if [ "$attempt" -eq 10 ]; then
echo "Migration timed out"
exit 1
fi
done
juju status -m target-controller:test-migrate
juju switch test-migrate
attempt=0
until [[ $(juju status ubuntu) ]]; do
echo "ubuntu not found, waiting..."
juju status ubuntu
if [[ ${attempt} -eq 10 ]]; then
exit 1
fi
sleep 1;
attempt=$((attempt+1))
done
juju deploy ubuntu yet-another-ubuntu
attempt=0
until [[ $(juju status yet-another-ubuntu) ]]; do
echo "yet-another-ubuntu not found, waiting..."
juju status yet-another-ubuntu
if [[ ${attempt} -eq 10 ]]; then
exit 1
fi
sleep 1;
attempt=$((attempt+1))
done
- name: Get debug info
if: failure()
run: |
set -x
echo " - Migration source status"
juju status -m source-controller:controller --format json || true
juju status -m source-controller:test-migrate --format json || true
echo " - Migration source controller logs"
juju debug-log -m source-controller:controller || true
echo " - Migration target status"
juju status -m target-controller:controller --format json || true
juju status -m target-controller:test-migrate --format json || true
echo " - Migration target controller logs"
juju debug-log -m target-controller:controller || true