-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(refresh): bug with revisions #1067
Conversation
4d56e56
to
d44b2a1
Compare
5482461
to
890ba55
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, couple of changes needed, and all the tests related to this need to pass.
juju/application.py
Outdated
|
||
charmhub = self.model.charmhub | ||
charm_resources = await charmhub.list_resources(charm_name) | ||
origin = client.CharmOrigin( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this out into a helper function and have some unit tests against this to protect the logic for any regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What logic exactly are you referring to here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More like decisions I meant to say, we make a bunch of decisions here, it would be nice if we have unit tests that assert those decisions so if any of them are violated in the future we'd catch it before it breaks.
source=str(Source.CHARM_HUB),
risk=channel.risk if channel else current_origin.risk,
track=channel.track if channel else current_origin.track,
revision=revision or current_origin.revision,
base=current_origin.base,
architecture=current_origin.get('architecture', DEFAULT_ARCHITECTURE),
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
56b16bc
to
7ae2a4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks very good, thanks for adding the extra unit tests 👍
We'll land it as soon as the check job is fixed.
643231b
to
7ae2a4d
Compare
/merge |
1 similar comment
/merge |
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. Replicate this method, ensuring we behave the same as the CLI. Fixes: juju#1057
7ae2a4d
to
956aa5a
Compare
/merge |
#1071 ## What's Changed * fix parsing of storage constraints by @luissimas in #1053 * Add setuptools to tox.ini by @Aflynn50 in #1058 * fix(refresh): bug with revisions by @jack-w-shaw in #1067 * feat: conventional commits static analysis by @SimonRichardson in #1068 * fix(series): add noble support by @jack-w-shaw in #1063 * fix zones constrains list parsing by @luissimas in #1054 * fix(model): fix wrong instanciation of list-secrets facade by @gboutry in #1065 * fix(makefile): run .tox before lint in makefile target by @cderici in #1069
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
Integration tests
Manual tests