Unnecessary call to 'apt update' on empty user-data
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init (Ubuntu) |
Fix Released
|
Critical
|
Unassigned | ||
Focal |
Invalid
|
Undecided
|
Unassigned | ||
Jammy |
Invalid
|
Undecided
|
Unassigned | ||
Lunar |
Invalid
|
Undecided
|
Unassigned | ||
Mantic |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
=== Begin SRU Template ===
[Impact]
Upstream commit 015543d304[1] introduced the ability to install missing dependencies (software-
The commit also introduced a default case on first boot where, regardless of whether apt configuration is present, apt update will be called.
This adds an initial boot delay of around 2 seconds and apt update should be avoided unless packages are going to be installed or `package_update: true` is provided in cloud-config user-data.
The fix is to avoid calling apt-get update in default case when no missing dependencies are required for installation.
[Test Case]
* launch daily mantic images with no user-data and confirm apt-get update is called by cloud-init on first boot
* upgrade cloud-init in the mantic VM to the proposed SRU cloud-init deb
* cloud-init clean --logs --reboot to re-run upgraded cloud-init across reboot
* assert that newly booted upgraded VM no longer calls apt-get update
test procedure:
cat > setup-proposed.sh <<EOF
#/bin/bash
mirror=http://
echo deb \$mirror \$(lsb_release -sc)-proposed main | tee /etc/apt/
apt-get update -q;
apt-get install -t \$(lsb_release -sc)-proposed -qy cloud-init;
EOF
cat sru-2039621.sh <<EOF
#!/bin/bash
for release in mantic; do
VM=sru-
lxc launch ubuntu-
lxc exec $VM -- cloud-init status --wait --long
APT_UPDATE_
[ -n "$APT_UPDATE_CALLS" ] || echo "FAILURE: did not find expected apt-get update calls on empty user-data" && echo "SUCCESS: found apt-get update calls $APT_UPDATE_CALLS"
echo " --- Assert apt-get update called across clean reboot on released pkg"
lxc exec $VM -- cloud-init clean --logs --reboot
sleep 5
lxc exec $VM -- cloud-init status --wait --long
APT_UPDATE_
[ -n "$APT_UPDATE_CALLS" ] || echo "FAILURE: did not find expected apt-get update calls on empty user-data" && echo "SUCCESS: found reproducer: $(echo $APT_UPDATE_CALLS | wc -l ) apt-get update call across clean reboot for published cloud-init"
echo "---- install proposed cloud-init"
lxc file push setup-proposed.sh $VM/
lxc exec $VM -- bash /setup-proposed.sh | grep cloud-init
RELEASE_
lxc file push $RELEASE_DEB $VM/
lxc exec $VM -- dpkg -i /$RELEASE_DEB
echo " --- Assert apt-get update NOT called across clean reboot on proposed pkg"
lxc exec $VM -- cloud-init clean --logs --reboot
sleep 5
lxc exec $VM -- cloud-init status --wait --long
APT_UPDATE_
[ -z "$APT_UPDATE_CALLS" ] || echo "FAILURE: found $(echo $APT_UPDATE_CALLS | wc -l ) unexpected apt-get update calls per boot: $APT_UPDATE_CALLS" && echo "SUCCESS: found NO apt-get update logs per boot on empty user-data"
lxc delete $VM --force
done
EOF
bash sru-2039621.sh # look for SUCCESS|FAIL messages
[Regression Potential]
If done wrong, minimal images may not attempt to install gnupg or software-
This regression test is already covered by https:/
[Other info]
Existing integration test for installing missing dependencies https:/
[Original description]
Upstream commit 015543d304[1] introduced the ability to install missing dependencies (software-
The commit also introduced a default case on first boot where, regardless of whether apt configuration is present, apt update will be called.
This adds an initial boot delay of around 2 seconds and apt update should be avoided unless packages are going to be installed or `package_update: true` is provided in cloud-config user-data.
[1] https:/
The resolution here is to avoid calling the method cloud.distro.
Changed in cloud-init (Ubuntu): | |
status: | Triaged → Fix Committed |
description: | updated |
description: | updated |
description: | updated |
Upstream PR: https:/ /github. com/canonical/ cloud-init/ pull/4519