'snap wait' fails when enabling livepatch
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-advantage-tools (Ubuntu) |
Fix Released
|
Undecided
|
Lucas Albuquerque Medeiros de Moura |
Bug Description
[Impact]
This bug results in ua failing to enable livepatch with no guidance to the user on how to resolve the issue. This only happens when the user has an older version of snapd installed.
The fix prints a new helpful message when this situation is detected. The message instructs the user to update snapd, which resolves the issue. Without this fix, users may give up while trying to enable livepatch and miss out on its benefits.
[Test Plan]
Reproduce the bug by trying to attach ua on a vm with an old version of snap. For example:
```
multipass launch -n test-xenial-
multipass shell test-xenial-
# inside the vm now
sudo apt update
sudo apt install snapd=2.0.2 ubuntu-
sudo apt install ubuntu-
sudo ua attach YOUR_UA_TOKEN_HERE
```
You should see the error described in this bug below.
To see the fix in action: detach, install the new version of ua from our staging ppa and try again.
```
sudo ua detach
sudo add-apt-repository ppa:ua-
sudo apt update
sudo apt install ubuntu-
sudo ua attach YOUR_UA_TOKEN_HERE
```
Enabling livepatch will still likely fail, but ua will output a suggestion to update snapd, which will resolve the issue.
[Where problems could occur]
The fix works by catching an exception when calling `snap wait` and printing the helpful message. It is possible that, if a mistake was made, we may catch a different error and print this message even though it is unrelated.
The fix also relies on the structure of the error message from snapd. If the error message structure were to change, this message won't be triggered properly.
[Other Info]
This issue is really a manifestation of ua's implied dependency on a recent version of snapd when enabling livepatch. ua doesn't require snapd for all features though, which is why it is not an explicit dependency. For example, a common use of ua is to enable a fips certified kernel (which is actually incompatible with livepatch). For those situations, there is no need for snapd to be installed or up to date.
[Original Description]
While trying to reproduce https:/
```
Enabling default service esm-infra
Updating package lists
UA Infra: ESM enabled
Enabling default service livepatch
Unexpected error(s) occurred.
For more details, see the log: /var/log/
To file a bug run: ubuntu-bug ubuntu-
```
`/var/log/
```
2021-05-06 08:31:30,867 - contract.py:(274) [ERROR]: Unexpected error processing contract delta for livepatch: {'entitlement': {'affordances': {'kernelFlavors': ['generic', 'lowlatency', 'oem', 'aws'], 'series': ['trusty', 'xenial', 'bionic', 'focal'], 'minKernelVersion': '4.4', 'tier': 'updates', 'architectures': ['amd64', 'x86_64']}, 'entitled': True, 'obligations': {'enableByDefault': True}, 'directives': {'caCerts': '', 'remoteServer': 'https:/
Traceback (most recent call last):
File "/usr/lib/
series_
File "/usr/lib/
orig_access, deltas, allow_enable=
File "/usr/lib/
if super()
File "/usr/lib/
self.enable()
File "/usr/lib/
[SNAP_CMD, "wait", "system", "seed.loaded"], capture=True
File "/usr/lib/
out, err = _subp(args, rcs, capture, timeout, env=env)
File "/usr/lib/
stderr=
uaclient.
```
Additional information
-------
```
ubuntu@
Description: Ubuntu 16.04.1 LTS
Release: 16.04
```
```
ubuntu@
ubuntu-
Installed: 27.0~16.04.1
Candidate: 27.0~16.04.1
Version table:
*** 27.0~16.04.1 500
500 http://
100 /var/lib/
27.0~16.04.1 500
500 http://
```
```
ubuntu@
snap 2.14.2~16.04
snapd 2.14.2~16.04
series 16
ubuntu 16.04
```
Hi Domas, thanks for reporting this issue. Can I ask you which AMI id did you use to launch the image and get this traceback ? I am unable to reproduce it using this AMI:
ami-05b0f906c5f 1814e7