Skip to content
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

Update juju api version used to 3.3 #402

Merged
merged 8 commits into from
Feb 14, 2024
Merged

Conversation

hmlanigan
Copy link
Member

@hmlanigan hmlanigan commented Feb 9, 2024

Description

First updating the version of go used by this project to 1.21, which matches the version used by juju 3.3 branch.

Updates necessary with move to juju 3.3 api libraries.

  • Create a logger shim to allow the provider logger to be passed to and used by the juju api clients.
  • Update use of the juju/core/series package to the juju/core/base package. The series package has been removed.

Updated 3 of the GitHub workflows to replace juju 3.1 with 3.2. Once 3.3.2 is released, we can update to 3.3. 3.3.2 will fix the bug mentioned in the qa steps.

Type of change

  • Maintenance work (repository related, like Github actions, or revving the Go version, etc.)

Environment

  • Juju controller version: 2.9, 3.3

  • Terraform version: any

QA steps

Run the acceptance tests against a juju 2.9.47 controller and a 3.3/edge controller with no problem. You'll have to use the juju 2.9/edge snap to bootstrap. Due to this, some of the acceptance tests will have to be run manually and the GitHub action jobs will fail until juju 2.9.47 is released.

The failure in some 3.3 tests "Unable to create model, got error: interface conversion: interface {} is nil, not string" has been fixed by #16822 and is not yet in a released version of juju 3.3

Additional notes

JUJU-5121

@hmlanigan hmlanigan added this to the 0.11.0 milestone Feb 9, 2024
Create a shim to map the terraform client logging to a juju Logger. This
is in anticipation of the juju 3.3.0 changes to apiclient.NewClient,
which will require a Logger.
Requires replacement of the core/series package use with core/base; a
set of base helper methods to replace set.Strings funcationality; use
of the new juju logger shim when calling apiclient.NewClient.
The provider is now using the 3.3 apis for juju. Let's test against that
version and the oldest supported 2.9
Some of the places where setup-go was used, didn't specify a go version
or where to find the version. After the update of go.mod to use go 1.21,
some of the workflows started to fail due to the version of go. Avoid
this in the future by adding go-version-file to the places it's missing.
Reduce files touched, was catching dependencies with go 1.21. Update to
version 1.54.0
3.3.1 has a bug which will cause the tests to fail. Test against 3.2
  until 3.3.2 has been released.
Copy link
Contributor

@cderici cderici left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Ignore the comments about the 3.3, didn't see your last commit in time, I was going through all the errors I was seeing, it might be worth to add a TODO in the code to change it after the 3.3.1 bug is resolved.

@@ -52,7 +52,7 @@ jobs:
- "1.6.*"
juju:
- "2.9/stable"
- "3.1/stable"
- "3.2/stable"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- "3.2/stable"
- "3.3/stable"

@@ -45,10 +45,10 @@ jobs:
juju-channel: "2.9/stable"
- cloud: "lxd"
cloud-channel: "5.19/stable"
juju-channel: "3.1/stable"
juju-channel: "3.2/stable"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
juju-channel: "3.2/stable"
juju-channel: "3.3/stable"

- cloud: "microk8s"
cloud-channel: "1.28-strict/stable"
juju-channel: "3.1/stable"
juju-channel: "3.2/stable"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
juju-channel: "3.2/stable"
juju-channel: "3.3/stable"

@@ -45,9 +48,9 @@ jobs:
terraform: ["1.4.*", "1.5.*", "1.6.*"]
action-operator:
- { cloud: "lxd", cloud-channel: "5.19", juju: "2.9" }
- { cloud: "lxd", cloud-channel: "5.19", juju: "3.1" }
- { cloud: "lxd", cloud-channel: "5.19", juju: "3.2" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- { cloud: "lxd", cloud-channel: "5.19", juju: "3.2" }
- { cloud: "lxd", cloud-channel: "5.19", juju: "3.3" }

- { cloud: "microk8s", cloud-channel: "1.28", juju: "2.9" }
- { cloud: "microk8s", cloud-channel: "1.28-strict", juju: "3.1" }
- { cloud: "microk8s", cloud-channel: "1.28-strict", juju: "3.2" }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- { cloud: "microk8s", cloud-channel: "1.28-strict", juju: "3.2" }
- { cloud: "microk8s", cloud-channel: "1.28-strict", juju: "3.3" }

if err != nil {
return nil, err
}
urlForOrigin = urlForOrigin.WithSeries(userSuppliedSeries)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth checking what happens when a revision is specified, where the value of urlForOrigin will be overwritten by this line if a base is provided.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WithSeries method of the URL will not overwrite the updates made by using WithRevision. The two With methods are updating independent pieces of the url and will not conflict.

// a private object.
func (c applicationsClient) seriesToUse(modelconfigAPIClient *apimodelconfig.Client, inputSeries, suggestedSeries string, charmSeries set.Strings) (string, error) {
c.Tracef("seriesToUse", map[string]interface{}{"inputSeries": inputSeries, "suggestedSeries": suggestedSeries, "charmSeries": charmSeries.Values()})
func (c applicationsClient) baseToUse(modelconfigAPIClient *apimodelconfig.Client, inputBase, suggestedBase base.Base, charmBases []base.Base) (base.Base, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is strange to me that we don't have unit tests for these functions, though that's beyond the scope of this PR, just wanted to note. I know that stuff we use from upstream (e.g. WorkloadBases(), ParseBaseFromString()) are tested there, but we do have some logic here that's covering a bunch of different scenarios, I feel like we should have unit tests for them (e.g. intersectionOfBases, basesContain since it uses IsCompatible).

Not just in this change, I feel like we should have unit tests for anything that starts with a lowercase letter in the internal/juju package.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on some unit tests for ReadApplicationWithRetryOnNotFound to help fix a different problem right now. However it'll be a bit trying to get more complete coverage. It's something we can chip away at for sure.

@hmlanigan
Copy link
Member Author

@cderici I'll put a PR to set the tests to 3.3 - we can remember to merge it once we can get successful tests, i.e. 3.3.2 exists.

@hmlanigan hmlanigan merged commit 3f7dc79 into juju:main Feb 14, 2024
16 of 23 checks passed
@hmlanigan hmlanigan deleted the use-juju-3-3-new branch February 14, 2024 21:36
@hmlanigan hmlanigan mentioned this pull request Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants