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

fix: improve model import #1534

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from

Conversation

kian99
Copy link
Contributor

@kian99 kian99 commented Jan 27, 2025

Description

This PR aims to fix issues recently noticed with imported models created by local users.

Importing a model into JIMM that is owned by a local Juju user requires the use of the --switch-owner CLI flag to change the model owner in jimm to a new external user. This change doesn't propagate to the Juju controller so extra logic needs to exist to ensure we alias the old user to the new one.

That was not being done and as a result, things like listing application offers were not working. This change allows models created by local Juju users to keep their model owner tag in JIMM. Although JIMM normally deals with external users, there is no reason it can't also hold local users for cases of model imports.

To handle the cloud-credential of an imported model where JIMM is not aware of the local user's credentials, we allow the value of the cloud-credential in JIMM to be nil. This works out because we fetch model info from the controller anyway.

This change simultaneously fixes the same issue addressed in #1533 where application offers that have already been consumed in a Juju model are being authorized by checking JIMM through the use of the JAAS macaroon discharger. If we can combine this change with the idea in #1533 to store the permissions of existing consumers of an app offer (including local users) we can solve both challenges.

Engineering checklist

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

Test instructions

Importing a model owned by a local Juju user requires the use of the --switch-owner CLI flag to change the model owner in jimm to a new external user. This change doesn't propagate to the Juju controller so there needs to be a lot of complex logic to ensure we replace all results containing the old user with the new one.

That was not being done and as a result, things like listing application offers were not working. This change allows models created by local Juju users to keep their model owner tag in JIMM. Although JIMM normally deals with external users, there is no reason it can't also hold local users for cases of model imports.

To handle the cloud-credential of an imported model where JIMM is not aware of the local user's credentials, we allow the value of the cloud-credential in JIMM to be nil. This works out because we fetch model info from the controller anyway.
@kian99 kian99 requested a review from a team as a code owner January 27, 2025 08:34
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.

1 participant