Juju incorrectly sets the charm origin during charm switches

Bug #2039270 reported by Jack Shaw
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Canonical Juju
Triaged
High
Jack Shaw

Bug Description

Replicated in juju 3.3 and 2.9

```
$ juju deploy ubuntu
Located charm "ubuntu" in charm-hub, revision 24
Deploying "ubuntu" from charm-hub charm "ubuntu", revision 24 in channel stable on focal
$ juju refresh ubuntu --switch ./ubuntu
Added local charm "ubuntu", revision 12, to the model

$ juju mongo
juju:PRIMARY> db.applications.find().pretty()
...
{
 "_id" : "e87c04ee-bffa-4f41-8f75-03379fe9d25d:ubuntu",
 "name" : "ubuntu",
 "model-uuid" : "e87c04ee-bffa-4f41-8f75-03379fe9d25d",
 "series" : "focal",
 "subordinate" : false,
 "charmurl" : "local:focal/ubuntu-12",
 "cs-channel" : "stable",
 "charm-origin" : {
  "source" : "local",
  "id" : "DksXQKAQTZfsUmBAGanZAhpoS4dpmXel",
  "hash" : "9b2877f7ebf04b348cf40ace32fdfc6d1cc0157dea7fd6740c4ba74e0e201e5b",
  "revision" : 24,
  "channel" : {
   "risk" : "stable"
  },
  "platform" : {
   "architecture" : "amd64",
   "os" : "ubuntu",
   "series" : "focal"
  }
 },
 "charmmodifiedversion" : 1,
 "forcecharm" : false,
 "life" : 0,
 "unitcount" : 1,
 "relationcount" : 0,
 "minunits" : 0,
 "txn-revno" : NumberLong(5),
 "metric-credentials" : BinData(0,""),
 "exposed" : false,
 "scale" : 0,
 "passwordhash" : "",
 "provisioning-state" : null,
 "txn-queue" : [
  "65291ff89dc55c1137a0eb17_b7251f98"
 ]
}
```

NOTE: the charm origin has been fixed to state the source is local, but the id, hash and channel are present (which is not valid for a local charm) and the revision is 24, despite the revision being changed to 12

The following I have only been able to replicate in 3.3. This does not happen in 2.9

The problems continue when we switch back to a charmhub charm
```
$ juju refresh ubuntu --switch postgresql
$ juju mongo
juju:PRIMARY> db.applications.find().pretty()
...
{
 "_id" : "1005126d-2370-41c8-8aef-629ba663f5db:ubuntu",
 "name" : "ubuntu",
 "model-uuid" : "1005126d-2370-41c8-8aef-629ba663f5db",
 "subordinate" : false,
 "charmurl" : "ch:amd64/jammy/postgresql-288",
 "charm-origin" : {
  "source" : "charm-hub",
  "type" : "charm",
  "id" : "DksXQKAQTZfsUmBAGanZAhpoS4dpmXel",
  "hash" : "9b2877f7ebf04b348cf40ace32fdfc6d1cc0157dea7fd6740c4ba74e0e201e5b",
  "revision" : 288,
  "channel" : {
   "track" : "14",
   "risk" : "stable"
  },
  "platform" : {
   "architecture" : "amd64",
   "os" : "ubuntu",
   "channel" : "22.04"
  }
 },
 "charmmodifiedversion" : 2,
 "forcecharm" : false,
 "life" : 0,
 "unitcount" : 1,
 "relationcount" : 2,
 "minunits" : 0,
 "txn-revno" : NumberLong(5),
 "metric-credentials" : BinData(0,""),
 "exposed" : false,
 "scale" : 0,
 "passwordhash" : "",
 "provisioning-state" : null
}
```

Notice how the channel, source, platform and revision have all correctly switched. But the id and hash have not changed

Jack Shaw (jack-shaw)
Changed in juju:
assignee: nobody → Jack Shaw (jack-shaw)
Changed in juju:
status: New → Triaged
importance: Undecided → High
Revision history for this message
Jack Shaw (jack-shaw) wrote :

This has been mostly resolved, but not entirely

See:
https://github.com/juju/juju/pull/16796#issuecomment-1910010705

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.