Snapcraft promote

Introduction

The snapcraft command line tool has a release command which has the following syntax,

$ snapcraft release <snap-name> <snap-revision> <channel>

Which allows to release revision <snap-revision> of <snap-name> to the desired <channel>. This is somewhat straightforward and simple to use. Alas, it becomes inconvenient when working with multiple architectures as such each snapcraft push to the Snap Store will be represented by a unique revision, so for the case of wanting to release a snap represented conceptually by a set multiple revisions we would need to do something like,

$ snapcraft release <snap-name> <snap-revision-arch-x> <channel>
$ snapcraft release <snap-name> <snap-revision-arch-y> <channel>
$ snapcraft release <snap-name> <snap-revision-arch-z> <channel>

Proposal

For the simple case of migrating a batch of revisions for a snap from one channel risk to another the proposal is to introduce a new command,

$ snapcraft promote <snap-name> <channel> [--to <to-channel>]

Where <channel> is the channel to promote from up to the next channel risk level. The user will have to acknowledge the promotion by being able to review the version string, timestamps of each revision and the revisions that will be released. Upon promoting, <channel> is closed and the user is notified.

The display of timestamps for revisions serves as a conceptual build-set a human can inspect to validate that releasing those revisions is indeed the desired intention.

The query of what to release is done to minimize any potential race conditions with regards to status changes of the channel map.

This orchestration of the promotion is a pure client side implementation. A log of changes will be recorded for the user to inspect.

This implementation does not cover anything for non-released snaps.

User stories

The baseline is that the user has a snap called lego-bricks registered on the store and has releases to edge for multiple architectures, such that,

$ snapcraft status lego-bricks
Track    Arch     Channel       Version             Revision
latest   amd64    -             -                   -
                  -             -                   -
                  -             -                   -
                  edge          1.0                 1
         arm64    -             -                   -
                  -             -                   -
                  -             -                   -
                  edge          1.0                 2
         i386     -             -                   -
                  -             -                   -
                  -             -                   -
                  edge          1.0                 3
         ppcel64  -             -                   -
                  -             -                   -
                  -             -                   -
                  edge          1.0                 4
         armhf    -             -                   -
                  -             -                   -
                  -             -                   -
                  edge          1.0                 5

Promote from edge to beta, answer yes

Considering the original status map,

$ snapcraft promote lego-bricks edge
The status map upon completion will look like:
Track    Arch     Channel       Version             Revision  Release Timestamp
latest   amd64    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 1         2018-06-14T11:06:04.311655
                  edge          ^                   ^
         arm64    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 2         2018-06-14T11:16:04.311655
                  edge          ^                   ^
         i386     stable        -                   -
                  candidate     -                   -
                  beta          1.0                 3         2018-06-14T11:08:04.311655
                  edge          ^                   ^
         ppcel64  stable        -                   -
                  candidate     -                   -
                  beta          1.0                 4         2018-06-14T11:10:04.311655
                  edge          ^                   ^
         armhf    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 5         2018-06-14T11:05:04.311655
                  edge          ^                   ^
Proceed? [yN] y
The beta channel is now open.
The edge channel is now closed.

Promote from edge to beta, answer no

Considering the original status map, the user notices something is off with armhf and cancels the promotion,

$ snapcraft promote lego-bricks edge
The status map upon completion will look like:
Track    Arch     Channel       Version             Revision  Release Timestamp
latest   amd64    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 1         2018-06-14T11:06:04.311655
                  edge          ^                   ^
         arm64    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 2         2018-06-14T11:16:04.311655
                  edge          ^                   ^
         i386     stable        -                   -
                  candidate     -                   -
                  beta          1.0                 3         2018-06-14T11:08:04.311655
                  edge          ^                   ^
         ppcel64  stable        -                   -
                  candidate     -                   -
                  beta          1.0                 4         2018-06-14T11:10:04.311655
                  edge          ^                   ^
         armhf    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 10        2017-06-14T11:05:04.311655
                  edge          ^                   ^
Proceed? [yN] n
No changes to the release channels have been made.

From beta to candidate, beta closed, answer yes

Considering the original status map,

$ snapcraft promote lego-bricks edge --to candidate
The status map upon completion will look like:
Track    Arch     Channel       Version             Revision  Release Timestamp
latest   amd64    stable        -                   -
                  candidate     1.0                 1         2018-06-14T11:06:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         arm64    stable        -                   -
                  candidate     1.0                 2         2018-06-14T11:16:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         i386     stable        -                   -
                  candidate     1.0                 3         2018-06-14T11:08:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         ppcel64  stable        -                   -
                  candidate     1.0                 4         2018-06-14T11:10:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         armhf    stable        -                   -
                  canditate     1.0                 5         2018-06-14T11:05:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
Proceed? [yN] y
The candidate channel is now open.
The edge channel is now closed.

From beta to candidate, beta open, answer yes

Considering the original status map, and a prior release to beta,

$ snapcraft promote lego-bricks edge --to candidate
The status map upon completion will look like:
Track    Arch     Channel       Version             Revision  Release Timestamp
latest   amd64    stable        -                   -
                  candidate     1.0                 1         2018-06-14T11:06:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         arm64    stable        -                   -
                  candidate     1.0                 2         2018-06-14T11:16:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         i386     stable        -                   -
                  candidate     1.0                 3         2018-06-14T11:08:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         ppcel64  stable        -                   -
                  candidate     1.0                 4         2018-06-14T11:10:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
         armhf    stable        -                   -
                  canditate     1.0                 5         2018-06-14T11:05:04.311655
                  beta          ^                   ^
                  edge          ^                   ^
Proceed? [yN] y
The candidate channel is now open.
The edge channel is now closed.
The beta channel is now closed.

Promote from edge to beta, answer yes, errors on close

Considering the original status map, and a fictional case of a user not being able to close channels,

$ snapcraft promote lego-bricks edge
The status map upon completion will look like:
Track    Arch     Channel       Version             Revision  Release Timestamp
latest   amd64    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 1         2018-06-14T11:06:04.311655
                  edge          ^                   ^
         arm64    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 2         2018-06-14T11:16:04.311655
                  edge          ^                   ^
         i386     stable        -                   -
                  candidate     -                   -
                  beta          1.0                 3         2018-06-14T11:08:04.311655
                  edge          ^                   ^
         ppcel64  stable        -                   -
                  candidate     -                   -
                  beta          1.0                 4         2018-06-14T11:10:04.311655
                  edge          ^                   ^
         armhf    stable        -                   -
                  candidate     -                   -
                  beta          1.0                 5         2018-06-14T11:05:04.311655
                  edge          ^                   ^
Proceed? [yN] y
The beta channel is now open.
An error occurred when trying to close edge: <store-error>
The full transcript of actions can be inspected at /tmp/snapcraft-promote-lego-bricks-4534231.log
$ cat /tmp/snapcraft-promote-lego-bricks-4534231.log
<timestamp> do release lego-bricks 5 beta
<timestamp> success release lego-bricks 5 beta
<timestamp> do release lego-bricks 4 beta
<timestamp> success release lego-bricks 4 beta
<timestamp> do release lego-bricks 3 beta
<timestamp> success release lego-bricks 3 beta
<timestamp> do release lego-bricks 2 beta
<timestamp> success release lego-bricks 2 beta
<timestamp> do release lego-bricks 1 beta
<timestamp> success release lego-bricks 1 beta
<timestamp> do close lego-bricks
<timestamp> fail close lego-bricks: you do not have permissions to close channels

Promote beta to candidate, beta closed

Considering the original status map,

$ snapcraft promote lego-bricks beta
Cannot promote lego-bricks from beta: the beta channel is closed.
Run `snapcraft status lego-bricks` to view the current state of
the channel map.

Promote beta to candidate, grade devmode

Considering the original status map, where a previous promotion of edge took place,

$ snapcraft promote lego-bricks beta
Cannot promote lego-bricks from beta: revision 3 and 4 have grade set to devmode.
Learn more about using grade at <snapcraft-grade-docs>.

Opens

  • Should we allow promotion of branches? What if the branches are not available on all architectures?
  • Should we allow for --to? If so, what is the correct behavior with regards to channel closing and should it allow switching tracks?

Work items

  • snapcraft: Implement user stories
  • Snap Store: Verify and if not provide timestamp of when a revision was released in the Snap Store Developer APIs.

Forward looking

  • Snap Store: Add support for transactional operations to execute in batch.
2 Likes

I have certainly experienced this problem :slight_smile: I have a use case for either not closing the “from” channel or allowing multiple “to” channels, which is that my go snaps are pushed to 1.X/candidate by launchpad, and then for the latest release I want to promote it to both 1.X/stable and latest/stable.

This proposal assumes that edge is always newer than beta (and so on), which in my experience is not always the case. As a result, I’m not sure how I feel about automatically closing channels. Let’s say my channel map looks like this:

$ snapcraft status lego-bricks
Track    Arch     Channel       Version             Revision
latest   amd64    -             -                   -
                  -             -                   -
                  beta          1.1-beta            6
                  edge          1.0                 1
         arm64    -             -                   -
                  -             -                   -
                  beta          1.1-beta            7
                  edge          1.0                 2
         i386     -             -                   -
                  -             -                   -
                  beta          1.1-beta            8
                  edge          1.0                 3
         ppcel64  -             -                   -
                  -             -                   -
                  beta          1.1-beta            9
                  edge          1.0                 4
         armhf    -             -                   -
                  -             -                   -
                  beta          1.1-beta            10
                  edge          1.0                 5

And I run snapcraft promote edge --to candidate. If beta were closed, folks tracking beta would end up refreshing to an older version. If beta were left open and edge closed, folks on edge would end up using the one from beta, which doesn’t seem desired either. The only reasonable thing to do is leave them open and let the user take care of it.

Also, this.

If we do --to at all, this is certainly a consideration. The --to is mostly something I came up with post discussions I wanted to through in for some corner cases like this.

If you have revisions of snaps that are newer in beta than in edge I would have to say that that is pretty strange and maybe this feature is probably not meant for you and you could stick to the convoluted task of releasing (the use of channel risk is already convoluted after all), consider that --to may not happen at all and the picture is complete, it is a promotion from one channel risk to the other.

Overall the proposal makes sense but let me know how this use case will unfold…

Let’s imagine we start with a 1.0 version on every architecture…


$ snapcraft status lego-bricks
Track    Arch     Channel       Version             Revision
latest   amd64    -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.0                 1
         arm64    -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.0                 2
         i386     -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.0                 3
         ppcel64  -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.0                 4

If I wanted to include a hotfix on 1.0 i386, I would update the current version architecture. Does it make sense?

What if I wanted to include a feature only available for i386 and make 1.1 for this architecture?


$ snapcraft status lego-bricks
Track    Arch     Channel       Version             Revision
latest   amd64    -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.0                 1
         arm64    -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.0                 2
         i386     -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.1                 3
         ppcel64  -             -                   -
                  -             -                   -
                  beta          -                   -
                  edge          1.0                 4

The only question I have is …

What would happen if I promote edge in this case?

  • Would it promote everything on the edge channel to beta?
  • Would it display an error message stating that version is different from the rest? In this case, we might want further confirmation from the publisher so is aware of it?
1 Like

I think an error with an override flag is reasonable. The original motivation I heard for promote was to address the case where automation gives you architecture builds in edge and you forget to the promote all but the one you use (amd64, typically). If the version strings are different, that is an indication but not confirmation that these revisions in edge are unrelated.

As well, I think it’s important to lock down behaviour to prevent misunderstanding of this feature.

I believe that it should promote exactly what is on those channels and that the visual confirmation is the queue to consider moving forward or not.

I do not wish to overload promote when release <snap-name> <revision> <channel> is perfectly capable of this. We could try and be smarter in the future when we can tag these builds and provide hints into maybe wanting to use the release command instead right before the yes/no prompt.

edge will be closed indeed. You may be better off using release, this feels like a corner case of something that shouldn’t be…
If you had a 1.1 and 1.0 track the promote workflow should be just fine.

The fact that use of --to is something I just came up with and not part of the original agreement, it could be possible that this is not even a problem as if you promote edge it will probably just land on beta.