[Bug 1924766] Re: update-notifier does not handle ESM Apps in the apt-check script
Lucas Albuquerque Medeiros de Moura
1924766 at bugs.launchpad.net
Wed Apr 28 13:57:42 UTC 2021
I have tested this package for released xenial, bionic, focal and
hirsute with the following script:
----------------------
#!/bin/sh
set -x
series=hirsute
name=$series-dev
function generate_motd_message() {
message=$1
echo "-----------------------------------------------------------"
echo $message
lxc exec $name -- /usr/lib/update-notifier/update-motd-updates-available --force
lxc exec $name -- update-motd
echo "-----------------------------------------------------------"
}
function turn_distro_into_esm_mode() {
# guarantee that xenial distro is on ESM mode
lxc exec $name -- sed -i 's/is_esm_supported and is_not_currently_supported/True #comment/' /usr/lib/update-notifier/apt-check
}
function turn_distro_into_non_esm_mode() {
# guarantee that xenial distro is on ESM mode
lxc exec $name -- sed -i 's/True #comment/False/' /usr/lib/update-notifier/apt-check
}
function setup_update_notifier() {
# lxc exec $name -- add-apt-repository ppa:lamoura/update-notifier-test-ppa -y
# lxc exec $name -- apt update
# lxc exec $name -- apt install update-notifier-common -y
# lxc exec $name -- apt update
# lxc exec $name -- apt install python3-distro-info
# lxc file push data/apt_check.py $name/usr/lib/update-notifier/apt-check
lxc exec $name -- sh -c "cat <<EOF >/etc/apt/sources.list.d/ubuntu-$series-proposed.list
deb http://archive.ubuntu.com/ubuntu/ $series-proposed restricted main multiverse universe"
lxc exec $name -- apt update
lxc exec $name -- sh -c "apt install update-notifier -yq > /dev/null"
}
function install_ua() {
lxc exec $name -- add-apt-repository ppa:ua-client/daily -y
lxc exec $name -- sudo apt-get update
lxc exec $name -- sudo apt-get install ubuntu-advantage-tools -y
lxc exec $name -- ua version
lxc exec $name -- sudo apt-get update
}
function ua_attach() {
lxc exec $name -- sed -i 's/contracts.can/contracts.staging.can/' /etc/ubuntu-advantage/uaclient.conf
lxc exec $name -- ua attach $UACLIENT_BEHAVE_CONTRACT_TOKEN_STAGING
}
function ua_detach() {
lxc exec $name -- ua detach --assume-yes
}
function generate_ua_motd_messages() {
lxc exec $name -- python3 /usr/lib/ubuntu-advantage/ua_update_messaging.py
}
function install_update_motd() {
lxc exec $name -- apt install update-motd -yq
}
function turn_esm_apps_into_non_beta() {
lxc exec $name -- sh -c "echo 'features:\n allow_beta: true' >> /etc/ubuntu-advantage/uaclient.conf"
}
function update_contract_effectiveto() {
operation=$1
num_days=$2
replace_date=$(date -d "$date $operation$num_days days" +"%Y-%m-%dT00:00:00Z")
echo $replace_date
lxc exec $name -- sed -i "s/\"effectiveTo\": \"[^\"]*\"/\"effectiveTo\": \"$replace_date\"/g" /var/lib/ubuntu-advantage/private/machine-token.json
}
lxc delete --force $name
lxc launch ubuntu-daily:$series $name
sleep 10
setup_update_notifier
install_update_motd
generate_motd_message "$series: ua not installed"
install_ua
turn_esm_apps_into_non_beta
generate_ua_motd_messages
turn_distro_into_esm_mode
generate_motd_message "$series esm: ua not attached"
ua_attach
generate_ua_motd_messages
generate_motd_message "$series esm: ua attached"
turn_distro_into_non_esm_mode
ua_detach
generate_ua_motd_messages
generate_motd_message "$series non-esm: ua not attached"
ua_attach
generate_ua_motd_messages
generate_motd_message "$series non-esm: ua attached"
update_contract_effectiveto - 30
generate_ua_motd_messages
generate_motd_message "$series esm: ua attached - contract expired"
update_contract_effectiveto - 5
generate_ua_motd_messages
generate_motd_message "$series esm: ua attached - contract grace period"
update_contract_effectiveto + 5
generate_ua_motd_messages
generate_motd_message "$series esm: ua attached - contract expire soon"
set +x
-------------------------
I can confirm that on all release, the package now in proposed is
working as expected
** Tags removed: verification-needed verification-needed-bionic verification-needed-focal verification-needed-hirsute verification-needed-xenial
** Tags added: verification-done verification-done-bionic verification-done-focal verification-done-hirsute verification-done-xenial
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to update-notifier in Ubuntu.
https://bugs.launchpad.net/bugs/1924766
Title:
update-notifier does not handle ESM Apps in the apt-check script
Status in update-notifier package in Ubuntu:
In Progress
Status in update-notifier source package in Xenial:
Fix Committed
Status in update-notifier source package in Bionic:
Fix Committed
Status in update-notifier source package in Focal:
Fix Committed
Status in update-notifier source package in Groovy:
New
Status in update-notifier source package in Hirsute:
Fix Committed
Status in update-notifier source package in Impish:
In Progress
Bug description:
[Impact]
When ESM Apps goes into production we want to be able to advertise it to our users through MOTD.
Currently, update-notifier apt-check does not take into consideration the exclusive packages of ESM Apps, which is a problem.
[Test case]
To reproduce the issue, you can:
1. Launch a xenial vm
2. Install the latest version of uaclient from the stable ppa:
https://launchpad.net/~ua-client/+archive/ubuntu/stable/
3. Change the following line on `/etc/ubuntu-advantage/uaclient.conf` from
contract_url: 'https://contracts.canonical.com'
To:
contract_url: 'https://contracts.staging.canonical.com'
4. Attach a staging token to uaclient thorough:
ua attach YOUR_STAGING_TOKEN
5. Run /usr/lib/update-notifier/apt-check --human-readable
6. Verify that no mention to ESM Apps is made and that update-notifier puts all of the ESM packages in the same bucket
To verify that the error is fixed:
1.Perform all the stages above until step 4
2 Install the new update-notifier from this ppa:
https://launchpad.net/~lamoura/+archive/ubuntu/update-notifier-test-ppa
3. Verify now that ESM Apps is reflected in the message
[Where problems could occur]
The changes in this package should only be seen when MOTD is getting a
new message. If that script fails for some reason, it seems that MOTD
will only not present the message, which is doesn't seem to be a
system critical issue.
[Discussion]
With ESM Apps going to production soon, we have decided to update the
messages delivered by update-notifier apt-check to address the package
count of ESM Apps and the possibility of installing more upgrades if
the user has ESM Apps disabled.
We are also updating other parts of the messaging as well. First, we only display ESM Infra status
on ESM distros. However, we will keep showing the ESM Infra package count on all of them.
For ESM Apps, we are only performing the alerts (For example, that you
might have x packages updates if ESM Apps is installed) if the user is
on a LTS distro.
Finally, we are also addressing this bug here:
https://bugs.launchpad.net/ubuntu/+source/update-notifier/+bug/1883315
Where we were incorrectly counting ESM packages even if the user did
not have access to those services.
== Changelog ==
+ data/apt-check
- Make distinction of ESM Apps and ESM Infra when doing package count
- Only count ESM packages if the user has access to the service (LP #1883315)
- Only display ESM Infra alerts if the distro is ESM
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/update-notifier/+bug/1924766/+subscriptions
More information about the foundations-bugs
mailing list