-
Notifications
You must be signed in to change notification settings - Fork 430
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
💎 cloud: Refactor Subnets scope to interface #768
Conversation
Opening the PR to get some feedback because I'm not 100% sure if I did that correctly. cc @CecileRobertMichon @devigned |
@CecileRobertMichon done the missing parts and add a few more test cases. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a couple points of feedback.
14a22de
to
1d79586
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, /assign @devigned for another review on the getExisting subnet changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subnet Reconcile
is a little tough to follow. Perhaps, a light bit of refactoring would help.
cloud/services/subnets/subnets.go
Outdated
func (s *Service) Reconcile(ctx context.Context) error { | ||
for i, subnetSpec := range s.Scope.SubnetSpecs() { | ||
existingSubnet, err := s.getExisting(ctx, s.Scope.Vnet().ResourceGroup, subnetSpec) | ||
if err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about the following refactor to clean things up a bit:
for i, subnetSpec := range s.Scope.SubnetSpecs() {
existingSubnet, err := s.getExisting(ctx, s.Scope.Vnet().ResourceGroup, subnetSpec)
switch {
case err != nil && !azure.ResourceNotFound(err):
// not found
case err != nil:
// stuff for existing subnet
case !s.Scope.Vnet().IsManaged(s.Scope.ClusterName()): // why does is managed need `s.Scope.ClusterName()`?
// if the vnet is unmanaged, we expect all subnets to be created as well
default:
// stuff to create new subnet
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to call out: "why does is managed need s.Scope.ClusterName()
?" Seems odd to have to pass in s.Scope.ClusterName()
when calling a func off of hierarchical descendant of s.Scope
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's because IsManaged is on the infra VnetSpec, not the scope itself.
this could also read:
vnet := s.Scope.Vnet() // return type *infrav1.VnetSpec
if !vnet.IsManagedBy(s.Scope.ClusterName()) {
...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could change this into s.Scope.IsVnetManaged() though
Agree it seems a bit odd like this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made all the requested changes, please take a look again :) thanks for all inputs!
@CecileRobertMichon was missing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Looks like my rebase did went well. Will fix that tomorrow |
/test pull-cluster-api-provider-azure-e2e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more comment based on #806 to fix parallelism in the tests
@cpanato: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: CecileRobertMichon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What this PR does / why we need it:
Follow up from #716 , this PR applies the same pattern to Subnets.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes partially #757
Special notes for your reviewer:
Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.
TODOs:
Release note: