[Bug 1926819] Re: Empty MOTD on up-to-date systems (includes fix)
Lucas Albuquerque Medeiros de Moura
1926819 at bugs.launchpad.net
Tue Jun 1 21:07:36 UTC 2021
I can confirm that the xenial, bionic, focal and hirsute packages are
working as expected.
To perform the verification I have used the following script:
--------------------------------------
#!/bin/sh
set -x
series=xenial
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 -- 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_from_branch() {
lxc exec $name --cwd /var/tmp/uac -- apt-get update
lxc exec $name --cwd /var/tmp/uac -- apt-get install make
lxc exec $name -- git clone https://github.com/canonical/ubuntu-advantage-client.git /var/tmp/uac
lxc exec $name --cwd /var/tmp/uac -- sh -c "make deps > /dev/null"
lxc exec $name --cwd /var/tmp/uac -- sh -c "DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -us -uc > /dev/null"
lxc exec $name -- apt-get remove ubuntu-advantage-tools --assume-yes
lxc exec $name --cwd /var/tmp/uac -- dpkg -i /var/tmp/ubuntu-advantage-tools_27.0_amd64.deb
lxc exec $name -- ua version
}
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_disable_esm_apps() {
lxc exec $name -- sudo ua disable esm-apps
}
function install_all_upgrades() {
lxc exec $name -- sudo sh -c "apt update > /dev/null"
lxc exec $name -- sudo sh -c "apt upgrade -y > /dev/null"
}
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"
ua_disable_esm_apps
generate_ua_motd_messages
generate_motd_message "$series esm: ua attached, apps disabled"
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"
install_all_upgrades
generate_ua_motd_messages
generate_motd_message "$series esm: ua attached - all upgrades installed"
set +x
-----------------------------
I verified the messages and they are consistent with the modifications
delivered by the proposed package
** 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/1926819
Title:
Empty MOTD on up-to-date systems (includes fix)
Status in update-notifier package in Ubuntu:
Fix Released
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 Hirsute:
Fix Committed
Bug description:
[Impact]
On a system without updates to be installed, not showing any message in motd feels that something went wrong in the backend. Also, currently we are printing unwanted white spaces in that scenario, which is not a good user experience here.
[Test case]
To reproduce the issue, you can:
1. Launch a xenial container
2. Remove ubuntu-advantage-tools from the system
This package will make update-notifier show more messages which are not needed in that test
3. Run an apt update
4. Install update-notifier
5. Run apt upgrade
6. Run /usr/lib/update-notifier/apt_check.py --human-readable
7. Verify we deliver an empty message
To verify that the error is fixed:
1. Run the past scenario until step 4
2. Install the new update-notifier from this ppa:
https://launchpad.net/~lamoura/+archive/ubuntu/update-notifier-test-ppa/
3. Run `/usr/lib/update-notifier/apt-check --human-readable`
4. Verify that the command print the following message:
0 updates can be applied immediately.
[Where problems could occur]
We are bringing back a behavior that was already present in the
package, but removed in the last version of it. We will now be
impacting users that may not be relying in that message anymore. But
we believe this should not be a huge issue if that happens, since
users were already relying on the old behavior.
[Discussion]
Currently, motd will not output a message if the system does not have any updates to apply. However, this is not ideal since this may cause the impression that there is something wrong with motd or the system. Also, the empty message we produce in that scenario is not completely empty, it does contain some white spaces on it, which is completely unnecessary.
Because of that, we are bringing back the behavior of printing the
message:
0 updates can be applied immediately.
If no updates need to be applied in the system.
[Original description]
Starting with update-notifier-common 3.192.30.7 (focal), my up-to-date systems are showing this MOTD on login:
Welcome to Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-72-generic x86_64)
user at host:~$
I've attached a patch that fixes this issue and adds more test cases.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/update-notifier/+bug/1926819/+subscriptions
More information about the foundations-bugs
mailing list