juju / python-libjuju

Python library for the Juju API
Apache License 2.0
57 stars 93 forks source link

[Refresh] revision option does not work #1057

Open phvalguima opened 1 month ago

phvalguima commented 1 month ago

Description

I am currently deploying OpenSearch operator: https://charmhub.io/opensearch

Writing an integration test that must start on rev. 90 (latest currently is rev. 95) and then jump: 90 > 91 > 95

However, the first jump above fails. Does not matter how I configure it, it always jumps: 90 > 95.

I have tried:

        await application.refresh(
            channel=OPENSEARCH_CHANNEL,
            rev=91,
        )

Also:

        await application.refresh(
            channel=OPENSEARCH_CHANNEL,
            switch="ch:amd64/jammy/opensearch-91",
        )

And still seeing the same issue.

One thing I've noticed, we are using "ResolveCharms" facade version 6. There are newer versions.

I also built juju for debug and inspected both what libjuju is sending and what juju refresh command sends.

Here are the comparison:

$ juju refresh opensearch --revision 91

...

# In my controller, I can see with GDB:
345 // ResolveCharms resolves the given charm URLs with an optionally specified
346 // preferred channel.  Channel provided via CharmOrigin.
347 func (a *API) ResolveCharms(args params.ResolveCharmsWithChannel) (params.ResolveCharmWithChannelResults, error) {
348 logger.Tracef("ResolveCharms %+v", args)
349 if err := a.checkCanRead(); err != nil {
350 return params.ResolveCharmWithChannelResults{}, errors.Trace(err)
351 }
(gdb) p args
$1 = {Resolve = []github.com/juju/juju/rpc/params.ResolveCharmWithChannel = {{Reference = "ch:amd64/jammy/opensearch-91", Origin = {Source = "charm-hub",
        Type = "", ID = "", Hash = "", Risk = "edge", Revision = 0xc004975a60, Track = 0xc00390c760, Branch = 0x0, Architecture = "amd64", Base = {
          Name = "ubuntu", Channel = "22.04/stable"}, InstanceKey = ""}, SwitchCharm = true}}, Macaroon = 0x0}
(gdb) c

With libjuju, where my code is set with:

        await application.refresh(
            channel=OPENSEARCH_CHANNEL,
            rev=91,
        )

I can see:

425 // ResolveCharms resolves the given charm URLs with an optionally specified
426 // preferred channel.  Channel provided via CharmOrigin.
427 // We need to include SupportedSeries in facade version 6
428 func (a *APIv6) ResolveCharms(args params.ResolveCharmsWithChannel) (params.ResolveCharmWithChannelResultsV6, error) {
429 res, err := a.API.ResolveCharms(args)
430 if err != nil {
431 return params.ResolveCharmWithChannelResultsV6{}, errors.Trace(err)
432 }
(gdb) p args
$2 = {Resolve = []github.com/juju/juju/rpc/params.ResolveCharmWithChannel = {{Reference = "ch:amd64/jammy/opensearch-90", Origin = {Source = "charm-hub",
        Type = "", ID = "e2tadLYMpAXYCht7PpgYV6Kzu6pkPw8s", Hash = "d3ec8b61c62f042eecf8b609eb037224bffd347148d52144979b80f101bc0600", Risk = "edge",
        Revision = 0xc0042aee70, Track = 0xc00474e8a0, Branch = 0x0, Architecture = "amd64", Base = {Name = "ubuntu", Channel = "22.04"},
        InstanceKey = "lF6PdF_2Z3MHUtSLLiq1-sk7m_DQ4q5NM-78Pa3VCtE"}, SwitchCharm = false}}, Macaroon = 0x0}

Urgency

Annoying bug in our test suite

Python-libjuju version

3.4.0.0

Juju version

3.4.2 and 3.6-beta1 (built from source)

Reproduce / Test

juju deploy opensearch --revision 90 --channel=2/edge

# Then, execute a small script with:
        await application.refresh(
            channel="2/edge",
            rev=91,
        )

# It will upgrade to a later version
jack-w-shaw commented 1 week ago

The parameter is revision not rev, but regardless, I have been able to replicate this bug using the correct parameter