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(internal/db/cloud.go): add virtual field to CloudRegion #1516

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

alesstimec
Copy link
Collaborator

Description

When we add a cloud reports no cloud regions we add a virtual "default" region to keep the
controller lookup logic the same when adding a model. Then only difference is that we do not send
the cloud region name in ModelCreateArgs to the controller.

Engineering checklist

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

Test instructions

@alesstimec alesstimec requested a review from a team as a code owner January 10, 2025 10:32
grantJIMMModelAdmin: func(_ context.Context, _ names.ModelTag) error {
return nil
},
createModel: assertCreateModelArgs(&jujuparams.ModelCreateArgs{
Copy link
Contributor

Choose a reason for hiding this comment

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

This test case and the corresponding assertCreateModelArgs are super confusing to read. Why is this pattern needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

just continuing the pattern that was here before which is not all that confusing.. think of it as middleware: each function checks a certain aspect of the call and passes check to the next one

Copy link
Contributor

@kian99 kian99 Jan 10, 2025

Choose a reason for hiding this comment

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

I took a look at the other test cases and I see what you mean that it's following the pattern. I think they're all extremely confusing, the whole test is really hard to read.

In any case, regarding the stuff inside assertCreateModelArgs. Why are we asserting that the fields match when we also have expectModel which is likely being used inside the test to verify the created model matches what is expected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

expectModel asserts that our database looks the way we expect it - it does not assert the arguments sent to the controller to create a new model.
the assertCreateModelArgs asserts that what we send to the controller contains parameters we thing should be sent to the controller - in this test case the cloud region should not be sent since it's a virtual one

Copy link
Contributor

@kian99 kian99 Jan 10, 2025

Choose a reason for hiding this comment

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

Ahh I understand, that is nice but tough to parse. Grabbing lunch then I'll take a closer look with that in mind. But seems fine to me

@alesstimec alesstimec force-pushed the virtual-default-cloud-region branch from 2c5e0c4 to 797578b Compare January 10, 2025 10:51
// clouds with no regions; e.g. maas or k8s clouds may not have regions,
// yet for some cloud juju creates a "default" region, while for others
// it does not.
Virtual bool
Copy link
Contributor

Choose a reason for hiding this comment

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

premise: i don't know if you can add a region after a cloud has been created.

In case you can, we should mark the region as virtual and then remove the virtual region once a real region is added.

Copy link
Contributor

Choose a reason for hiding this comment

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

additional question: if we mark the region as Virtual we don't need to add a fake default region anymore as you did in the previous PR. Right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i do not know if it is possible to add regions: theoretically we could add a controller that would bring with it additional regions for a cloud.. but then that becomes a more complicated issue - is this a public cloud, is it private, is it even the same cloud, etc..

on the second questions: yes, we still need to add a default "virtual" region

When we add a cloud reports no cloud regions we add a virtual "default" region to keep the
controller lookup logic the same when adding a model. Then only difference is that we do not send
the cloud region name in ModelCreateArgs to the controller.
@alesstimec alesstimec force-pushed the virtual-default-cloud-region branch from 797578b to 5b8b195 Compare January 10, 2025 12:13
@alesstimec alesstimec merged commit 6d08538 into canonical:v3 Jan 10, 2025
4 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