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

Bug #1859211 reported by Adam Stokes
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snap Layer
Fix Released
Undecided
Unassigned
snapd
Fix Released
Critical
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'],
        stdin=subprocess.DEVNULL,
        universal_newlines=True
    )
    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.

Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

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).

Revision history for this message
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
Revision history for this message
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)
Changed in snapd:
status: New → Triaged
importance: Undecided → Critical
Michael Vogt (mvo)
Changed in snapd:
status: Triaged → In Progress
Revision history for this message
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)
Changed in snapd:
status: In Progress → Fix Committed
Revision history for this message
Adam Stokes (adam-stokes) wrote :

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

Revision history for this message
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)
Changed in snapd:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.