juju refresh to revision is ignored w/ charmhub

Bug #1988556 reported by Tom Haddon
20
This bug affects 5 people
Affects Status Importance Assigned to Milestone
Canonical Juju
Fix Committed
High
Heather Lanigan

Bug Description

I was running revison 60 of my charm and wanted to revert to revision 57, so I ran:

$ juju refresh indico --revision=57 --channel=edge
Added charm-hub charm "indico", revision 61 in channel edge, to the model
Leaving endpoints in "alpha": db, indico-peers, ingress, metrics-endpoint, redis

As you can see, I got revision 61 rather than 57. What is the correct way of downgrading a k8s charm, and could that command be updated to warn you that it wouldn't actually refresh you to revision 57, rather than just upgrading to the latest in that channel?

The juju model is on 2.9.32 and the juju client is 2.9.33-ubuntu-amd64 in case that's relevant.

Revision history for this message
John A Meinel (jameinel) wrote :
Download full text (4.4 KiB)

As far as I can tell, we ignore the '--revision' when doing `juju refresh`. I tried this with just a normal charm:

$ juju model-config -m controller logging-config="<root>=INFO;#charmhub=TRACE"
$ juju refresh ubuntu-lite --revision 9 --channel latest/stable
charm "jameinel-ubuntu-lite", revision 10: already up-to-date

And in
$ juju debug-log -m controller

machine-0: 08:47:51 TRACE juju.apiserver.charms.charmhubrepo.client charmhub Refresh(charmhub.refreshOne{
    ID: "BlASLTVIpvpYo4uac5rPxJ9Jji4wcgKQ",
    Revision: 10,
    Channel: "latest/stable",
    Base: charmhub.RefreshBase{Architecture:"amd64", Name:"ubuntu", Channel:"20.04"},
    instanceKey: "aNVoNhErQtBCGqPM_F6u5wITbndW3VQKZp9tUYEkv24",
    metrics: {},
    fields: {"bases", "config-yaml", "download", "id", "license", "metadata-yaml", "name", "publisher", "resources", "revision", "summary", "type", "version"},
})
machine-0: 08:47:51 TRACE juju.apiserver.charms.charmhubrepo.client charmhub POST request POST /v2/charms/refresh HTTP/1.1
Host: api.charmhub.io
Accept: application/json
Content-Type: application/json
User-Agent: Juju/2.9.34

{
  "context": [
    {
      "instance-key": "aNVoNhErQtBCGqPM_F6u5wITbndW3VQKZp9tUYEkv24",
      "id": "BlASLTVIpvpYo4uac5rPxJ9Jji4wcgKQ",
      "revision": 10,
      "base": {
        "architecture": "amd64",
        "name": "ubuntu",
        "channel": "20.04"
      },
      "tracking-channel": "latest/stable"
    }
  ],
  "actions": [
    {
      "action": "refresh",
      "instance-key": "aNVoNhErQtBCGqPM_F6u5wITbndW3VQKZp9tUYEkv24",
      "id": "BlASLTVIpvpYo4uac5rPxJ9Jji4wcgKQ",
      "base": null
    }
  ],
  "fields": [
    "bases",
    "config-yaml",
    "download",
    "id",
    "license",
    "metadata-yaml",
    "name",
    "publisher",
    "resources",
    "revision",
    "summary",
    "type",
    "version"
  ]
}

machine-0: 08:47:51 TRACE juju.apiserver.charms.charmhubrepo.client charmhub POST response HTTP/1.1 200 OK
Content-Length: 1539
Content-Type: application/json
Date: Fri, 02 Sep 2022 12:47:51 GMT
Server: gunicorn/20.0.4
Snap-Store-Version: 50
X-Request-Id: AE4645A7F3340A83255C01BB6311FB7720EB07C7
X-Vcs-Revision: 1a95ea7b
X-View-Name: snapdevicegw.webapi_refresh_charm.charm_refresh

{
  "error-list": [],
  "results": [
    {
      "charm": {
        "bases": [
          {
            "architecture": "amd64",
            "channel": "20.04",
            "name": "ubuntu"
          },
          {
            "architecture": "amd64",
            "channel": "18.04",
            "name": "ubuntu"
          },
          {
            "architecture": "amd64",
            "channel": "16.04",
            "name": "ubuntu"
          },
          {
            "architecture": "amd64",
            "channel": "14.04",
            "name": "ubuntu"
          }
        ],
        "config-yaml": "options: {}\n",
        "download": {
          "hash-sha-256": "caf33f5d5f2df199a80217a2746a8ff04c3fd02af5a5fad200887a5a9bf16015",
          "size": 16867,
          "url": "https://api.charmhub.io/api/v1/charms/downl...

Read more...

Changed in juju:
importance: Undecided → High
milestone: none → 2.9.35
status: New → Triaged
tags: added: charmhub refresh revision
Revision history for this message
John A Meinel (jameinel) wrote :
Download full text (21.2 KiB)

Testing with a juju prerelease
$ juju --version
2.9.34-ubuntu-amd64

Doing a fresh deploy with explicit revision I see that we make an initial request to Charmhub, asking about revision 8 (but we don't know the base).
For some reason we are making what looks like the exact same request 4 times,
but with a different instanceKey. (this might be fixed in 3.0)

```
2022-09-02 12:53:26 TRACE juju.apiserver.charms.charmhubrepo.client refresh.go:102 Refresh(charmhub.executeOneByRevision{
    Name: "jameinel-ubuntu-lite",
    Revision: &int(8),
    ID: "",
    resourceRevisions: nil,
    instanceKey: "8fa89cbe-a844-4f83-8d97-838c16e48d42",
    action: "install",
    fields: {"bases", "config-yaml", "download", "id", "license", "metadata-yaml", "name", "publisher", "resources", "revision", "summary", "type", "version"},
})
2022-09-02 12:53:26 TRACE juju.apiserver.charms.charmhubrepo.client http.go:190 POST request POST /v2/charms/refresh HTTP/1.1

Host: api.charmhub.io

Accept: application/json

Content-Type: application/json

User-Agent: Juju/2.9.34

{"context":[],"actions":[{"action":"install","instance-key":"8fa89cbe-a844-4f83-8d97-838c16e48d42","name":"jameinel-ubuntu-lite","revision":8,"base":null}],"fields":["bases","config-yaml","download","id","license","metadata-yaml","name","publisher","resources","revision","summary","type","version"]}

2022-09-02 12:53:27 TRACE juju.apiserver.charms.charmhubrepo.client http.go:203 POST response HTTP/1.1 200 OK

Content-Length: 1395

Content-Type: application/json

Date: Fri, 02 Sep 2022 12:53:27 GMT

Server: gunicorn/20.0.4

Snap-Store-Version: 50

X-Request-Id: AE4645A7F33C0A83255C01BB6311FCC620F57921

X-Vcs-Revision: 1a95ea7b

X-View-Name: snapdevicegw.webapi_refresh_charm.charm_refresh

{"error-list":[],"results":[{"charm":{"bases":[{"architecture":"amd64","channel":"16.04","name":"ubuntu"},{"architecture":"amd64","channel":"18.04","name":"ubuntu"},{"architecture":"amd64","channel":"14.04","name":"ubuntu"}],"config-yaml":"options: {}\n","download":{"hash-sha-256":"b030f6d755f53887106e2964383f1fa35517b783e12a0b1710d108a3bc0cdf32","size":16885,"url":"https://api.charmhub.io/api/v1/charms/download/BlASLTVIpvpYo4uac5rPxJ9Jji4wcgKQ_8.charm"},"id":"BlASLTVIpvpYo4uac5rPxJ9Jji4wcgKQ","license":"","metadata-yaml":"description: 'Run an Ubuntu system, but don''t do a whole lot else.\n\n '\nextra-bindings:\n another: null\nmaintainer: John Arbash Meinel <email address hidden>\nname: ubuntu-lite\nprovides:\n ubuntu:\n interface: ubuntu\nseries:\n- xenial\n- bionic\n- trusty\nsubordinate: false\nsummary: The smallest charm I could come up with that still looks nice.\ntags:\n- misc\n- application_development\n","name":"jameinel-ubuntu-lite","publisher":{"display-name":"John A Meinel","id":"9Xfx2ERmqDnUBmyV1MAlxnTSwuKb52B4","username":"jameinel","validation":"unproven"},"resources":[],"revision":8,"summary":"The smallest charm I could come up with that still looks nice.","type":"charm","version":"8"},"id":"BlASLTVIpvpYo4uac5rPxJ9Jji4wcgKQ","instance-key":"8fa89cbe-a844-4f83-8d97-838c16e48d42","name":"jameinel-ubuntu-lite","released-at":null,"...

Revision history for this message
John A Meinel (jameinel) wrote :

From discussing with Heather, it seems that the "Refresh" api provided by Charmhub doesn't let you target a revision (it only lets you refresh to the tip of the channel), so we'll actually need to use the "Install" that we use as part of `juju deploy`.

Revision history for this message
John A Meinel (jameinel) wrote :

Going through history, refresh to revision is just functionality against charmhub that we've never implemented. (juju refresh on charmhub has only ever supported going to the tip of a channel)
However, it is a downgrade from what you were able to do on Charm Store, so we should look to implement it.

summary: - unable to downgrade a k8s charm using most obvious syntax
+ `juju refresh: --revision is ignored`
summary: - `juju refresh: --revision is ignored`
+ juju refresh to revision is ignored w/ charmhub
Changed in juju:
milestone: 2.9.35 → 2.9.36
Changed in juju:
milestone: 2.9.36 → 2.9.37
Changed in juju:
milestone: 2.9.37 → 2.9.38
Changed in juju:
milestone: 2.9.38 → 2.9.39
Changed in juju:
milestone: 2.9.39 → 2.9.40
Changed in juju:
milestone: 2.9.40 → 2.9.41
Changed in juju:
milestone: 2.9.41 → 2.9.42
Changed in juju:
milestone: 2.9.42 → 2.9.43
Changed in juju:
milestone: 2.9.43 → 2.9.44
Changed in juju:
milestone: 2.9.44 → 2.9.45
Changed in juju:
assignee: nobody → Heather Lanigan (hmlanigan)
Changed in juju:
milestone: 2.9.45 → 2.9.46
Changed in juju:
status: Triaged → Fix Committed
Revision history for this message
Heather Lanigan (hmlanigan) wrote :

This was fixed in 2.9.45, 3.1.6 and 3.2.3

https://github.com/juju/juju/pull/16259/

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.