Merge ~ack/maas:deb-to-snap-migration-fix-db-access into maas:master

Proposed by Alberto Donato
Status: Merged
Approved by: Alberto Donato
Approved revision: baed0232212a531ca3a6a628eeeba6a48a2f7517
Merge reported by: MAAS Lander
Merged at revision: not available
Proposed branch: ~ack/maas:deb-to-snap-migration-fix-db-access
Merge into: maas:master
Diff against target: 32 lines (+11/-7)
1 file modified
snap/local/tree/bin/maas-deb-migrate (+11/-7)
Reviewer Review Type Date Requested Status
Björn Tillenius Approve
Review via email: mp+402344@code.launchpad.net

Commit message

LP: #1927340 - mas-deb-migrate: fix db patching process

This ensures bootsource entries are corretly updated when the migrating node is
a region controller, and uses Django rather than direct psql access to work
even if the database is not local

To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/snap/local/tree/bin/maas-deb-migrate b/snap/local/tree/bin/maas-deb-migrate
index febca85..f646f0f 100755
--- a/snap/local/tree/bin/maas-deb-migrate
+++ b/snap/local/tree/bin/maas-deb-migrate
@@ -65,17 +65,21 @@ cleanup_data() {
65}65}
6666
67apply_db_patches() {67apply_db_patches() {
68 if maas_snap_mode | grep -q "region"; then68 if ! maas_snap_mode | grep -q "region"; then
69 snap_run "maas-region migrate"69 return
70 fi70 fi
7171
72 snap_run "maas-region migrate"
72 # patch the value of the default cloud images keyring to point to the one73 # patch the value of the default cloud images keyring to point to the one
73 # in the snap74 # in the snap
74 local keyring="/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg"75 cat <<EOF | snap_run "maas-region shell"
75 cat <<EOF | pg_do psql maasdb76from maasserver.models import BootSource
76UPDATE maasserver_bootsource77keyring = "/usr/share/keyrings/ubuntu-cloudimage-keyring.gpg"
77SET keyring_filename = '${MAAS_SNAP}${keyring}'78(
78WHERE keyring_filename = '${keyring}'79 BootSource.objects
80 .filter(keyring_filename=keyring)
81 .update(keyring_filename=f"/snap/maas/current{keyring}")
82)
79EOF83EOF
80}84}
8185

Subscribers

People subscribed via source and target branches