core snap 2.43 introduces `host` line in snap version breaking charms

Bug #1859211 reported by Adam Stokes on 2020-01-10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Layer
Samuele Pedroni

Bug Description

If upgrading to core snap 16-2.43 a new line is introduced in snap version:

πŸ˜€ adam@adam-ThinkPad-W520:jenkins 🌴 snap version
snap 2.42.5
snapd 2.42.5
series 16
ubuntu 19.10
kernel 5.4.7-050407-generic

ubuntu@ip-172-31-6-5:~$ snap version
snap 2.43
snapd 2.43
series 16
ubuntu 18.04
kernel 4.15.0-1054-aws
host amd64 kvm

def _get_snapd_version():
    stdout = subprocess.check_output(
        ['snap', 'version'],
    version_info = dict(line.split() for line in stdout.splitlines())
    return LooseVersion(version_info['snapd'])

The code will then break due to the host line containing multiple items. This is critical as we are currently blocking snapd team from releasing their next update.

Related branches

The consequence of this change will be that every charm using the snap layer will break when snapd on the host updates to 2.43. The patch will fix the problem for newly built charms, but any charm that's already deployed and doesn't get upgraded to a version with the patch will break.

I think we should apply the patch for future-proofing, but I'd also like to propose that that format of the "host amd64 kvm" line be changed to "host amd64,kvm" (or anything else that results in two "words" per line).

Stuart Bishop (stub) wrote :

Agreed the host line needs changing back. This will break a lot of production deployments.

Changed in layer-snap:
status: New → Triaged
Stuart Bishop (stub) wrote :

Released the more defensive code in the snap layer.

snapd release still need to remain blocked however, at least until fallout can be determined with Bootstack, Field and IS.

Changed in layer-snap:
status: Triaged → Fix Committed
status: Fix Committed → Fix Released
Michael Vogt (mvo) on 2020-01-13
Changed in snapd:
status: New → Triaged
importance: Undecided → Critical
Michael Vogt (mvo) on 2020-01-13
Changed in snapd:
status: Triaged → In Progress
Samuele Pedroni (pedronis) wrote :

We are removing the extra host line (it was convenient for bug reporting but given it created problems we will add the information somewhere dedicated), nevertheless we cannot promise from snapd that versions will not have spaces in them though ever. That parsing code still look likes is making too many assumptions, something like:

version_info = dict(line.split() for line in stdout.splitlines() if line.startswith('snapd '))

is probably safer.

Michael Vogt (mvo) on 2020-01-14
Changed in snapd:
status: In Progress → Fix Committed
Adam Stokes (adam-stokes) wrote :

What about having some type of yaml/json format to the snap version output?

Samuele Pedroni (pedronis) wrote :

> What about having some type of yaml/json format to the snap version output?

Supporting some form of --format=json|yaml|... for many commands is in our backlog but so far has been lower priority than other larger features, also some things still need to stabilize a bit more

Changed in snapd:
assignee: nobody → Samuele Pedroni (pedronis)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers