A restart of these oneshot services may cause cloud-init to be unable to
setup apt repositories or install packages requested by cloud-init user-data.
Version 3.6-7ubuntu1 introduced a downstream change in behavior for Ubuntu
where needrestart will automatically restart services across
non-interactive apt-get dist-upgrade.
When cloud-init user-data provides both package_upgrade: true and requests
for either package installs or PPA setup, cloud-final.service will
call apt-get dist-upgrade in non-interactive mode and follow up with any
number of add-apt-repository or apt-get install commands. If cloud-init
is also a package being upgraded by dist-upgrade, needrestart to suggests that
the running cloud-final.service is a candidate for automatic restart.
This results in a SIGTERM to cloud-final.service that prevents the rest
of cloud-init's APT configuration from completing.
Given that /etc/cloud/cloud.cfg allows for the package_update_upgrade_install
module to be configured to run in other boot stages, we need to skip
restart on any of the 4 cloud-init boot stage services mentioned above.
autopkgtests set the frontend to noninteractive, but we actually want to
test what happens with the default frontend to check that the flow
doesn't get interrupted.