invalid track in channel name: /stable

Bug #1841475 reported by Paul Larson
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
snapd
Fix Released
Undecided
John Lenton

Bug Description

With snapd 2.41 (currently pre/beta), when trying to refresh a snap, I am getting the error:
error: cannot refresh "<snapname>": invalid track in channel name: /stable

we used to be able to refresh things by specifying something like "... --channel=$TRACK/stable" where track could be empty, because we have this templated since we don't always know if we'll need to specify a track or not with the snaps we are testing, so --channel=/stable would just use the default track. That seems to get an error now though.

[Reproducing]
This is easy to reproduce:
$ sudo snap install hello --channel=/stable
$ sudo snap refresh hello --beta
(you could use anything else too: --channel=/stable, --channel=edge, --edge, etc)
error: cannot refresh "hello": invalid track in channel name: /stable

This has always worked in the past, with this new 2.41 snapd was the first time I've seen that it didn't

[Impact]
In our case, we have some of our systems that we've used for testing that keep rolling forward/back as needed. Because of that, these systems already have most snaps installed in a state where they are tracking something like "/stable" or "/beta". Once a system like that is upgrade to include snapd 2.41, it can no longer refresh any of those snaps, without reverting snapd to 2.40. If others have systems where snaps have been installed or refreshed like this before, they would be similarly impacted.

Paul Larson (pwlars)
affects: snapstore → snapd
Revision history for this message
Daniel Manrique (roadmr) wrote :

Can you make the default value of $TRACK (i.e. if it's not assigned something else) "latest"?

something like TRACK={$TRACK:-latest}

Can you strip the leading slash so the channel spec if $TRACK is empty is only a risk name, which should work well and target the default track?

Something like

CHAN=`echo $TRACK/stable | sed 's/^\///'
--channel=$CHAN

(note that right now "default" track is always "latest" but that might change in the very near future with the "default" track functionality - so it's always best to specify "latest" explicitly if that's what you want, because you don't know when a snap author will designate a non-latest track as default.

Revision history for this message
Paul Larson (pwlars) wrote :

Moved to snapd because I noticed this system had snapd 2.41~pre1+git1056.g1c4c6d3 (4504) installed (this is a pi but other systems are seeing it too)

ijohnson and I were talking about it on irc and he pointed out there was a recent change that may be the culprit: https://github.com/snapcore/snapd/pull/7255

When I reverted to snapd stable (2.40), everything worked fine.

Revision history for this message
Daniel Manrique (roadmr) wrote :

Not a snap-store bug, the store correctly handles "/stable" as a channel spec. Maybe move this to snapd?

curl -X POST https://api.snapcraft.io/v2/snaps/refresh -H "Snap-Device-Store: ubuntu" -H "Snap-Accept-Delta-Format: xdelta" -H "Snap-Device-Series: 16" -H "Snap-Device-Architecture: armhf" -H "Content-type: application/json" -d \
    '{"context": [{"instance-key": "foo", "snap-id":"99T7MUlRhtI3U0QFgl5mXXESAiSwt776", "revision": 34, "tracking-channel": "/stable"}], "actions": [{"action": "refresh", "instance-key": "foo", "snap-id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776","channel": "/stable"}]}' | jq .

{
  "error-list": [],
  "results": [
    {
      "effective-channel": "stable",
      "instance-key": "foo",
      "name": "core",
      "released-at": "2019-08-12T13:50:58.132882+00:00",
      "result": "refresh",
      "snap": {
        "created-at": "2019-07-12T10:15:35.806696+00:00",
        "download": {
          "deltas": [],
          "sha3-384": "8801a2153d59de4750dc0dcb26d2a4b76c96f30f8f5573da5692f924ebc59ee7ae66466982da447d7c507f2734e88931",
          "size": 79355904,
          "url": "https://api.snapcraft.io/api/v1/snaps/download/99T7MUlRhtI3U0QFgl5mXXESAiSwt776_7398.snap"
        },
        "license": "Other Open Source",
        "name": "core",
        "prices": {},
        "publisher": {
          "display-name": "Canonical",
          "id": "canonical",
          "username": "canonical",
          "validation": "verified"
        },
        "revision": 7398,
        "snap-id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776",
        "summary": "snapd runtime environment",
        "title": "core",
        "type": "os",
        "version": "16-2.40"
      },
      "snap-id": "99T7MUlRhtI3U0QFgl5mXXESAiSwt776"
    }
  ]
}

Changed in snapd:
assignee: nobody → Facundo Batista (facundo)
assignee: Facundo Batista (facundo) → nobody
Revision history for this message
Ian Johnson (anonymouse67) wrote :

Okay, this is confirmed an issue for core 2.41, we previously allowed installing snaps with channel spec as "/stable", and now if snaps like that are installed, they cannot be refreshed after going from 2.40 -> 2.41. See:

```
$ sudo snap info core
name: core
summary: snapd runtime environment
publisher: Canonical✓
contact: <email address hidden>
license: unset
description: |
  The core runtime environment for snapd
type: core
snap-id: 99T7MUlRhtI3U0QFgl5mXXESAiSwt776
tracking: stable
refresh-date: today at 08:51 CDT
channels:
  stable: 16-2.40 2019-08-12 (7396) 92MB -
  candidate: 16-2.40 2019-07-17 (7396) 92MB -
  beta: 16-2.41~pre1 2019-08-20 (7640) 93MB -
  edge: 16-2.41~pre1+git1446.5a0fe61 2019-08-27 (7688) 93MB -
installed: 16-2.40 (7396) 92MB core
$ snap install hello-world --channel=/stable
hello-world 6.4 from Canonical✓ installed
$ snap refresh core --beta
2019-08-27T08:52:46-05:00 INFO Waiting for restart...
core (beta) 16-2.41~pre1 from Canonical✓ refreshed
$ snap refresh hello-world --beta
error: cannot refresh "hello-world": invalid track in channel name: /stable
```

The key point being that snaps installed with this channel spec prior to 2.41 are no longer refreshable after going to 2.41.

After talking with pedronis and mvo about it, we will not support installing with "/stable" as a channel spec going forward, so we will also need to add code blocking install with such a channel spec (which we aren't doing now at all)

Changed in snapd:
status: New → Confirmed
Paul Larson (pwlars)
description: updated
Revision history for this message
Samuele Pedroni (pedronis) wrote :

In the new world: https://forum.snapcraft.io/t/behavior-change-risk-only-channel-specifications-will-not-switch-track/11769/3

"stable" etc means switch risk only

Should /stable do that, or be equivalent to latest/stable (or later default/stable). I don't think there is an obvious answer, it's best not to guess here from my POV.

Changed in snapd:
assignee: nobody → Ian Johnson (anonymouse67)
Revision history for this message
Ian Johnson (anonymouse67) wrote :

In talking with pedronis, we decided that, when we encounter a channel spec of "/<some-risk>", we will change it to just "<some-risk>" rather than change it to "latest/<some-risk>".

First PR to fix this is up: https://github.com/snapcore/snapd/pull/7359, this blocks installing snaps with invalid channel specs as in the description.

Revision history for this message
Ian Johnson (anonymouse67) wrote :

Note there is an equivalent bug here with track names:

```
$ snap install edgex-device-mqtt --channel=/edinburgh/edge
edgex-device-mqtt (edinburgh/edge) 1.0.0-20190827+c5955bf from EdgeX Foundry (edgexfoundry✓) installed
$ snap refresh edgex-device-mqtt --beta
error: cannot refresh "edgex-device-mqtt": invalid risk in channel name: /edinburgh/edge
```

Revision history for this message
Ian Johnson (anonymouse67) wrote :

Second PR to patch old style "/stable" to "stable" is up here: https://github.com/snapcore/snapd/pull/7364

Revision history for this message
John Lenton (chipaca) wrote :

We'll be fixing things so these things work, but the old (unspecified) behaviour is deprecated and will print a warning that will become an error.

So, for now, --channel=$FOO/stable will work, but it will be an error soon (in a few releases).

Now, *for stable*, you could just say --channel="$FOO". That will DTRT and will continue to do so. For other risk levels, you'll have to do something like e.g. --channel="${FOO:+$FOO/}beta".

Changed in snapd:
assignee: Ian Johnson (anonymouse67) → John Lenton (chipaca)
Revision history for this message
Samuele Pedroni (pedronis) wrote :

We have this behavior now:

$ sudo snap install hello --channel=/stable
Warning: Specifying a channel "/stable" is relying on undefined behaviour. Interpreting it as
         "latest/stable" for now, but this will be an error later.

hello 2.10 from Canonical✓ installed

$ sudo snap refresh --beta hello
hello (beta) 2.10.1 from Canonical✓ refreshed

Changed in snapd:
status: Confirmed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

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