Commit d0a18d3
authored
Merge pull request #1067 from jack-w-shaw/JUJU-6262_fix_refresh_revision
#1067
#### Description
We are incorrectly refreshing charms. The current method queries the controller for the charm's current origin and charm url
In pylibjuju, we then just overwrite the appropriate fields. However, this leaves behind id_ and hash_
This means when we later refresh, we are always returned the most recent revision by charmhub, no matter what revision we specify.
The way we handle this in the Juju CLI is by reconstructing the charm origin using MakeOrigin:
https://github.com/juju/juju/blob/a03ade4d358b1b0f135374b15b1bcd6b46d0ba0f/cmd/juju/application/utils/origin.go#L20-L75
This ensures only the fields we expect are present.
Do something similar in pylibjuju, ensuring we behave the same as the CLI.
Fixes: #1057
#### QA Steps
Unit tests
```
tox -e unit
```
Integration tests
```
tox -e integration -- tests/integration/test_application.py::test_refresh_revision
```
Manual tests
```
$ juju bootstrap lxd lxd
$ juju add-model m
$ juju deploy opensearch --revision 90 --channel=2/edge
$ python -m asyncio
>>> from juju.model import Model
>>> m = Model()
>>> await m.connect()
>>> app = m.applicatyions["opensearch"]
>>> await app.refresh(revision=91)
>>> exit()
$ juju status
Model Controller Cloud/Region Version SLA Timestamp
m lxd1 localhost/localhost 3.6-beta1 unsupported 13:32:44+01:00
App Version Status Scale Charm Channel Rev Exposed Message
opensearch maintenance 1 opensearch 2/edge 91 no Installing OpenSearch...
Unit Workload Agent Machine Public address Ports Message
opensearch/0* maintenance executing 0 10.219.211.254 (install) Installing OpenSearch...
Machine State Address Inst id Base AZ Message
0 started 10.219.211.254 juju-56bc09-0 ubuntu@22.04 Running
```3 files changed
Lines changed: 90 additions & 20 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
691 | 692 | | |
692 | 693 | | |
693 | 694 | | |
694 | | - | |
695 | 695 | | |
| 696 | + | |
696 | 697 | | |
697 | | - | |
| 698 | + | |
698 | 699 | | |
699 | 700 | | |
700 | 701 | | |
| 702 | + | |
| 703 | + | |
701 | 704 | | |
702 | 705 | | |
703 | 706 | | |
| |||
706 | 709 | | |
707 | 710 | | |
708 | 711 | | |
709 | | - | |
710 | | - | |
711 | | - | |
712 | | - | |
713 | | - | |
714 | | - | |
715 | | - | |
716 | | - | |
717 | | - | |
718 | | - | |
719 | | - | |
720 | | - | |
721 | | - | |
722 | | - | |
723 | 712 | | |
724 | 713 | | |
725 | 714 | | |
| |||
761 | 750 | | |
762 | 751 | | |
763 | 752 | | |
764 | | - | |
765 | | - | |
| 753 | + | |
766 | 754 | | |
767 | 755 | | |
768 | 756 | | |
| |||
771 | 759 | | |
772 | 760 | | |
773 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
774 | 765 | | |
775 | 766 | | |
776 | 767 | | |
| |||
917 | 908 | | |
918 | 909 | | |
919 | 910 | | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
920 | 925 | | |
921 | 926 | | |
922 | 927 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
289 | 301 | | |
290 | 302 | | |
291 | 303 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
177 | 179 | | |
178 | 180 | | |
179 | 181 | | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
0 commit comments