Skip to content

feat: use jujuclient for clouds#1889

Merged
ale8k merged 5 commits intocanonical:v3from
ale8k:usejujuclient-for-clouds
Mar 3, 2026
Merged

feat: use jujuclient for clouds#1889
ale8k merged 5 commits intocanonical:v3from
ale8k:usejujuclient-for-clouds

Conversation

@ale8k
Copy link
Contributor

@ale8k ale8k commented Feb 26, 2026

Description

This PR updates the cloud client to use the juju client.

The primary changes of this PR are:

  • Updates our JIMM dep to the tip of 3.6 to include the new CheckCredentialsModels client method
  • Use jujuclient in clouds.go on all methods
  • Rename UpdateCredential -> UpdateCloudsCredentialForce to reflect what it actually is doing
  • Update client method CheckCredentialsModels godoc so it is clear why we have it and don't just call UpdateCloudsCredential without the force flag (as it performs this check for a single model)
  • Change return type of UpdateCloudsCredentialForce and CheckCredentialsModels to return the clients return type and not the nested Model field's type for two reasons:
    • Should we ever wish to remove the client, it will be easier as we handle the logic of parsing the error outside the package
    • It was duplicated across the two methods, now it is in a single location
  • Change Clouds() to return the type, for the same reason as above (should we ever wish to remove the client)

There's a little remaining work to refactor updateControllerCloudCredential, UpdateCloudsCredentialForce and CheckCredentialsModels actually take different parameters and we need this in our client right now. It would be preferable we don't have this in our client (again, in the event we wish to just delete the file).

Engineering checklist

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

@ale8k ale8k requested a review from a team as a code owner February 26, 2026 13:27
return nil, errors.E(err)
}

// Shouldn't happen, the Juju client presumes that
Copy link
Contributor

Choose a reason for hiding this comment

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

If we assume it won't happen, we should probably at least log if it does. Worth considering panicking as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah happy to add, the juju client code doesn't care about this but I wanted to just add a little precaution.

Copy link
Contributor

Choose a reason for hiding this comment

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

The other option is to remove the check entirely and let the index below panic. Up to you.

// UpdateCloudsCredentialForce updates the given credential on the controller.
// It calls UpdateCloudsCredentials, and adapts it to:
// 1. Take a single credential
// 2. Always force the update (force=true).
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So AFAICT, our previous code does the check + update separately to enable batch checking across controllers, as we update the credential for all controllers currently holding it.

Copy link
Contributor

@SimoneDutto SimoneDutto left a comment

Choose a reason for hiding this comment

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

i'm not fully clued up on this piece of work, but looks good to me

@ale8k
Copy link
Contributor Author

ale8k commented Mar 2, 2026

i'm not fully clued up on this piece of work, but looks good to me

Before merging, I'll explain tomorrow in standup so it is clearer

ale8k added 5 commits March 3, 2026 10:17
we update to the tip to include the new checkcredentialmodels client method
updates cloud method to return the cloud and not mutate pointer, this makes the client package
consistent and enables us to remove it at a later date
refactors check credentialmodels and updatecredential to call the error parsing logic in a
consistent location. additionally renames update credentials to reflect what it actually does.
@ale8k ale8k force-pushed the usejujuclient-for-clouds branch from ec95e8b to bf6c65d Compare March 3, 2026 10:17
@ale8k ale8k merged commit f4ad8b5 into canonical:v3 Mar 3, 2026
8 of 13 checks passed
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.

3 participants