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

fix(snapd): ubuntu do not snap refresh when snap absent #5259

Conversation

blackboxsw
Copy link
Collaborator

@blackboxsw blackboxsw commented May 3, 2024

Proposed Commit Message

fix(snapd): ubuntu do not snap refresh when snap absent

No longer call snap refresh when cloud-config user-data specifies upgade_packages:true and custom Ubuntu images do not have snapd package installed

LP: #2064300

Additional Context

My commit a6f7577 attempted to fix this issue, but the validation of the fix only looked at
update_packages: true config not upgrade_packages: true

During SRU validation we discovered that this former patch was not successful in closing the upgrade patches case.
https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/2064132

Test Steps

#!/bin/bash
set -ex
SERIES=$1

cat > pkg-upgrade.yaml <<EOF
#cloud-config
package_upgrade: true
EOF

#for SERIES in "focal" "jammy" "mantic"; do
for SERIES in "focal"; do
echo "---------- SRU verification: $SERIES"
name=test-no-snap-$SERIES
if [ "$SERIES" = "focal" ]; then
  LXC_CFG_KEY="user.user-data"
else
  LXC_CFG_KEY="cloud-init.user-data"
fi
lxc launch ubuntu-daily:$SERIES $name -c $LXC_CFG_KEY="$(cat pkg-upgrade.yaml)"
sleep 6
lxc exec $name -- cloud-init status --wait && echo "SUCCESS: upgrade success on system  with snapd" || echo "FAILED: package_upgrade error on system with snapd"

# assert snap refresh is called on system with snapd
lxc exec $name -- egrep 'snap.*refresh' /var/log/cloud-init.log && echo "SUCCESS: found snap refresh on system with snapd" || echo "FAILED: did not file snap refresh on system with snapd"

lxc exec $name -- apt-get remove snapd -y
lxc exec $name -- cloud-init clean --logs --reboot
sleep 6

lxc exec $name -- cloud-init status --wait || true # expect failure here because we aren't using the fixed version
lxc exec $name -- egrep 'snap.*refresh' /var/log/cloud-init.log && echo "SUCCESS: found snap refresh on failed system without snapd" || echo "FAILED: did not find snap refresh on failed system with snapd"

echo --- upgrade to proposed fix
lxc file push cloudinit/distros/ubuntu.py $name/usr/lib/python3/dist-packages/cloudinit/distros/
lxc exec $name -- cloud-init clean --logs --reboot
sleep 6

# expect no warnings/errors
lxc exec $name -- cloud-init status --wait --format=yaml || echo "FAILED: errors or warning found"

# ensure no calls to snap refresh
lxc exec $name -- egrep 'snap.*refresh' /var/log/cloud-init.log && echo "FAILED: found snap refresh system without snapd" || echo "SUCCESS: did not find snap refresh on system without snapd"

done

Checklist

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

No longer call snap refresh when cloud-config user-data
specifies upgade_packages:true and custom Ubuntu images
do not have snapd package installed

LP: #2064300
@blackboxsw blackboxsw force-pushed the ubuntu-no-snap-refresh-when-snapd-absent branch from ee91fc6 to a877f96 Compare May 3, 2024 21:06
Copy link
Member

@TheRealFalcon TheRealFalcon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll handle all of the cases one of these days!

Looks good once lints are fixed

@blackboxsw blackboxsw merged commit 51c6569 into canonical:main May 3, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants