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

✨ feat: create vpc objects in explicitly provided availability zones #4950

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

synthe102
Copy link
Contributor

@synthe102 synthe102 commented Apr 23, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

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 #4333, continues the work started by @Skarlso in this PR by:

  • moving de defaults for AvailabilityZoneSelection and AvailabilityZoneUsageLimit into defaulting webhooks instead of CRDs
  • adding check in validating webhooks for conflicting use of AvailabilityZoneUsageLimit and AvailabilityZoneSelection with AvailabilityZones

Special notes for your reviewer:

Checklist:

  • squashed commits
  • includes documentation
  • includes emojis
  • adds unit tests
  • adds or updates e2e tests

Release note:

Ability to specify Availability Zones from spec.network.vpc in AWSManagedControlPlane, AWSCluster and AWSClusterTemplate CRDs.

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Apr 23, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign justinsb for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Hi @synthe102. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 23, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 27, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 13, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 12, 2024
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 20, 2024
@AndiDog
Copy link
Contributor

AndiDog commented Jul 3, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 3, 2024
Copy link
Contributor

@AndiDog AndiDog left a comment

Choose a reason for hiding this comment

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

Please change the release note to something that's readable by users (.spec.vpc) instead of developers (VPCSpec), and best use a verb to describe the change.

api/v1beta2/awscluster_webhook.go Outdated Show resolved Hide resolved
api/v1beta2/awscluster_webhook.go Outdated Show resolved Hide resolved
api/v1beta2/network_types.go Show resolved Hide resolved
api/v1beta2/network_types.go Outdated Show resolved Hide resolved
pkg/cloud/services/network/subnets.go Show resolved Hide resolved
@synthe102 synthe102 force-pushed the main branch 6 times, most recently from 3e9ce4e to ca10c55 Compare July 17, 2024 09:25
@synthe102
Copy link
Contributor Author

@AndiDog Thanks a lot for this initial review. I addressed all your comments, all the tests are OK so far.

@synthe102
Copy link
Contributor Author

/test pull-cluster-api-provider-aws-verify

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 24, 2024
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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-sigs/prow repository.

Copy link
Contributor

@AndiDog AndiDog left a comment

Choose a reason for hiding this comment

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

I have a few minor suggestions that can mostly be included directly. Looks good overall. Only a rebase is needed after those changes, so the PR is mergeable (you may just have some conflicts that go away with git rebase origin/main && make generate).

Comment on lines +251 to +252
// by default, we will take the set availability zones, if they are defined.
// if not, we fall back to the two other settings.
Copy link
Contributor

Choose a reason for hiding this comment

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

"the two other" is a statement that could easily become outdated. Let's prefer absolute terms in documentation and comments:

Suggested change
// by default, we will take the set availability zones, if they are defined.
// if not, we fall back to the two other settings.
// By default, take the set availability zones. If they are not defined,
// fall back to `availabilityZoneUsageLimit`/`availabilityZoneSelection`

Comment on lines +349 to +350
}
if selectionScheme == infrav1.AZSelectionSchemeOrdered {
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
}
if selectionScheme == infrav1.AZSelectionSchemeOrdered {
} else if selectionScheme == infrav1.AZSelectionSchemeOrdered {

@@ -3071,6 +3071,176 @@ func TestReconcileSubnets(t *testing.T) {
stubMockCreateTagsWithContext(m, "test-cluster", "subnet-az-1a-private", "us-east-1a", "private", false).AnyTimes()
},
},
{
name: "Managed VPC, no existing subnets exist, one az is explicitly defined, expect one private and one public from default",
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
name: "Managed VPC, no existing subnets exist, one az is explicitly defined, expect one private and one public from default",
name: "Managed VPC, no subnets exist, one az is explicitly defined, expect one private and one public from default",

Comment on lines +3101 to +3129
m.DescribeAvailabilityZonesWithContext(context.TODO(), gomock.Any()).
Return(&ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
ZoneName: aws.String("us-east-1b"),
ZoneType: aws.String("availability-zone"),
},
},
}, nil)

m.DescribeAvailabilityZonesWithContext(context.TODO(), gomock.Any()).
Return(&ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
ZoneName: aws.String("us-east-1b"),
ZoneType: aws.String("availability-zone"),
},
},
}, nil)

m.DescribeAvailabilityZonesWithContext(context.TODO(), gomock.Any()).
Return(&ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
ZoneName: aws.String("us-east-1b"),
ZoneType: aws.String("availability-zone"),
},
},
}, nil)
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
m.DescribeAvailabilityZonesWithContext(context.TODO(), gomock.Any()).
Return(&ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
ZoneName: aws.String("us-east-1b"),
ZoneType: aws.String("availability-zone"),
},
},
}, nil)
m.DescribeAvailabilityZonesWithContext(context.TODO(), gomock.Any()).
Return(&ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
ZoneName: aws.String("us-east-1b"),
ZoneType: aws.String("availability-zone"),
},
},
}, nil)
m.DescribeAvailabilityZonesWithContext(context.TODO(), gomock.Any()).
Return(&ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
ZoneName: aws.String("us-east-1b"),
ZoneType: aws.String("availability-zone"),
},
},
}, nil)
m.DescribeAvailabilityZonesWithContext(context.TODO(), gomock.Any()).
Return(&ec2.DescribeAvailabilityZonesOutput{
AvailabilityZones: []*ec2.AvailabilityZone{
{
ZoneName: aws.String("us-east-1b"),
ZoneType: aws.String("availability-zone"),
},
},
}, nil).Times(3) // short comment why this is called multiple times (e.g. current implementation detail, loop through 3 objects, ... – this otherwise looks like a bug 🤷)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. needs-priority needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to specify Availability Zones from the VPCSpec object
3 participants