Commit 9e0e39d
authored
Merge pull request #978 from jack-w-shaw/JUJU-4779_switch_to_local_properly-master
#978
Ensure that we provide the server with a valid charm origin when switching to local charms. Previously, we simply sent back the same charm origin when switching to a local charm.
However, this is not valid, since we don't know where we switched from. If it's a charmhub charm, it's origin will not be valid.
Also, parse the revision from the new charm url the server sends us
This is equivalent to: juju/juju#16434
#### QA Steps
Edit line 26 of examples/local_refresh.py to point to a local ubuntu charm
```
$ juju deploy ubuntu
$ juju mongo
juju:PRIMARY> db.applications.find().pretty()
...
{
"_id" : "277dae9c-abe3-4aba-83e4-0a63622e2981:ubuntu",
"name" : "ubuntu",
"model-uuid" : "277dae9c-abe3-4aba-83e4-0a63622e2981",
"subordinate" : false,
"charmurl" : "ch:amd64/focal/ubuntu-24",
"charm-origin" : {
"source" : "charm-hub",
"type" : "charm",
"id" : "DksXQKAQTZfsUmBAGanZAhpoS4dpmXel",
"hash" : "9b2877f7ebf04b348cf40ace32fdfc6d1cc0157dea7fd6740c4ba74e0e201e5b",
"revision" : 24,
"channel" : {
"risk" : "stable"
},
"platform" : {
"architecture" : "amd64",
"os" : "ubuntu",
"channel" : "22.04"
}
},
"charmmodifiedversion" : 0,
"forcecharm" : false,
"life" : 0,
"unitcount" : 1,
"relationcount" : 0,
"minunits" : 0,
"txn-revno" : NumberLong(3),
"metric-credentials" : BinData(0,""),
"exposed" : false,
"scale" : 0,
"passwordhash" : "",
"provisioning-state" : null
}
$ python examples/local_refresh.py
$ juju mongo
juju:PRIMARY> db.applications.find().pretty()
...
{
"_id" : "277dae9c-abe3-4aba-83e4-0a63622e2981:ubuntu",
"name" : "ubuntu",
"model-uuid" : "277dae9c-abe3-4aba-83e4-0a63622e2981",
"subordinate" : false,
"charmurl" : "local:jammy/ubuntu-13",
"charm-origin" : {
"source" : "local",
"type" : "charm",
"id" : "DksXQKAQTZfsUmBAGanZAhpoS4dpmXel",
"hash" : "9b2877f7ebf04b348cf40ace32fdfc6d1cc0157dea7fd6740c4ba74e0e201e5b",
"revision" : 13,
"channel" : {
"risk" : "stable"
},
"platform" : {
"architecture" : "amd64",
"os" : "ubuntu",
"channel" : "22.04"
}
},
"charmmodifiedversion" : 1,
"forcecharm" : false,
"life" : 0,
"unitcount" : 1,
"relationcount" : 0,
"minunits" : 0,
"txn-revno" : NumberLong(4),
"metric-credentials" : BinData(0,""),
"exposed" : false,
"scale" : 0,
"passwordhash" : "",
"provisioning-state" : null
}
```
NOTE: This doesn't quite work as expected, but this is not a python-libjuju bug, but in juju/juju here:
https://github.com/juju/juju/blob/3.3/state/application.go#L1792-L1840
However, @hmlanigan is working on a fix (juju/juju#16315) that will resolve this, so proposing this change to python-libjuju as a stepping stone towards to complete solution
```
tox -e integration -- tests/integration/test_application.py::test_local_refresh
```
All CI tests need to pass.3 files changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
848 | 848 | | |
849 | 849 | | |
850 | 850 | | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
851 | 862 | | |
852 | 863 | | |
853 | 864 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| |||
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
235 | 252 | | |
236 | 253 | | |
237 | 254 | | |
| |||
0 commit comments