** Description changed: [ Impact ] * SRU of cloud-init 24.1.3 to Focal, Jammy and Mantic introduced a regression where cloud-init will attempt to call `snap refresh` on new Ubuntu instance launches if the Ubuntu image does not contain snapd deb package and optional #cloud-config user-data is provided which contains `upgrade_packages: true`. * Such optional user-data on custom ubuntu images will result in cloud-init exiting in error condition as seen from cloud-init status due to the following error message: - ('package_update_upgrade_install', ProcessExecutionError("Unexpected error while running command.\nCommand: ['snap', 'refresh']\nExit code: -\nReason: [Errno 2] No such file or directory: b'snap'\nStdout: -\nStderr: -")) This only affects new custom Ubuntu image launches where both of the following conditions are met: 1. image is a custom ubuntu image which does not contain snapd deb package 2. At instance launch, optional #cloud-config user-data contains `package_upgrade: true` Ubuntu cloudimages published by Canonical for Focal, Jammy and Mantic all currently have the snapd deb package installed. Even for custom Ubuntu images without snapd deb package installed, this issue is only triggered when #cloud-config contains the optional `package_upgrade: true` during instance launch. This error log does cause cloud-init status to exit non-zero, but it doesn't affect the integrity of the configuration applied to the system. It is just an undesirable error log message for an unsupported (snap) package manager within the environment. - [ Test Plan ] * # launch ubuntu cloud images in LXC, remove snapd, provide "#cloud-config\npackage_upgrade:true" as user-data and clean reboot to force cloud-init to attempt to upgrade any package managers (snap and apt) where applicable. * confirm no snap command present in image * check cloud-init status --format=yaml to ensure no errors * grep snap.*refresh /var/log/cloud-init.log to assert no stray snap refresh is attempted on an image without snap #!/bin/bash - lxc launch ubuntu-daily:jammy test-no-snap - sleep 3 - lxc exec test-no-snap -- cloud-init status --wait - lxc exec test-no-snap -- apt remove snapd -y - + SERIES=$1 cat > pkg-update.yaml <<EOF #cloud-config package_update: true EOF + lxc launch ubuntu-daily:$SERIES test-no-snap -c cloud-init.user-data="$(cat pkg-update.yaml)" + sleep 3 + lxc exec test-no-snap -- cloud-init status --wait + # assert snap refresh is called on system with snapd + lxc exec test-no-snap -- egrep 'snap.*refresh' /var/log/cloud-init.log - lxc config set test-no-snap cloud-init.user-data="$(cat pkg-update.yaml)" + lxc exec test-no-snap -- apt remove snapd -y lxc exec test-no-snap -- cloud-init clean --logs --reboot sleep 3 # expect no warnings/errors lxc exec test-no-snap -- cloud-init status --wait --format=yaml # ensure no calls to snap refresh lxc exec test-no-snap -- egrep 'snap.*refresh' /var/log/cloud-init.log [ Where problems could occur ] The bug above is an unwanted error log that results in cloud-init reporting an error state and non-zero exit code. The error log doesn't erode the actual final configuration applied to the machine, it just sets a state we don't wont to see as cloud-init shouldn't be trying and failing to run snap command if it doesn't exist in the environment. Given that this fix is only performing a subp.which("snap") to assert that the snap command exists in the path before attempting to run "snap refresh" regression potential is negligible. In the unlikely event that the code paths added do fail here, the regression impact woud only result in a slightly different error log that also doesn't impact the overall config applied to the instance at launch. [ Other Info ] ==== original description ==== In Ubuntu images that do not have snapd deb package installed, launching with the following user-data triggers cloud-init to run `snap refresh` when that command doesn't exist. reproducer: lxc launch ubuntu-daily:jammy test-no-snap sleep 3 lxc exec test-no-snap -- cloud-init status --wait lxc exec test-no-snap -- apt remove snapd -y cat > pkg-update.yaml <<EOF #cloud-config package_update: true EOF lxc config set test-no-snap cloud-init.user-data="$(cat pkg-update.yaml)" lxc exec test-no-snap -- cloud-init clean --logs --reboot sleep 3 # expect no warnings/errors lxc exec test-no-snap -- cloud-init status --wait --format=yaml # ensure no calls to snap refresh lxc exec test-no-snap -- egrep 'snap.*refresh' /var/log/cloud-init.logb
-- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2064132 Title: images without snapd installed error on `update_packages: true` user- data To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/2064132/+subscriptions -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs