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

[DualStack] Support NSG and clean LBs #3898

Merged
merged 2 commits into from Jun 21, 2023

Conversation

lzhecheng
Copy link
Contributor

What type of PR is this?

/kind feature

What this PR does / why we need it:

  • Support NSG and clean LBs for dualstack
  • Support related UTs for dualstack
  • Refactor

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?

* Support NSG and clean LBs for dualstack
* Support related UTs for dualstack
* Refactor

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@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. labels May 18, 2023
@netlify
Copy link

netlify bot commented May 18, 2023

Deploy Preview for kubernetes-sigs-cloud-provide-azure canceled.

Name Link
🔨 Latest commit 051a677
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cloud-provide-azure/deploys/64913ac7b24fdc0008b605dd

@k8s-ci-robot k8s-ci-robot requested a review from jwtty May 18, 2023 10:56
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 18, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lzhecheng

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested a review from nilo19 May 18, 2023 10:56
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 18, 2023
@lzhecheng
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2023
@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 25, 2023
@lzhecheng lzhecheng force-pushed the dualstack-nsg branch 3 times, most recently from a81bbfd to 7217c25 Compare May 30, 2023 09:04
@lzhecheng lzhecheng force-pushed the dualstack-nsg branch 2 times, most recently from 669012f to ed6e470 Compare June 6, 2023 09:35
@lzhecheng
Copy link
Contributor Author

/test pull-cloud-provider-azure-e2e-ccm-ipv6-capz
/test pull-cloud-provider-azure-e2e-ccm-ipv6-vmss-capz

@lzhecheng lzhecheng force-pushed the dualstack-nsg branch 2 times, most recently from d814ca9 to 59de6d3 Compare June 7, 2023 01:54
@lzhecheng
Copy link
Contributor Author

/test pull-cloud-provider-azure-e2e-ccm-ipv6-capz
/test pull-cloud-provider-azure-e2e-ccm-ipv6-vmss-capz

@lzhecheng
Copy link
Contributor Author

/retest

@lzhecheng lzhecheng force-pushed the dualstack-nsg branch 2 times, most recently from 4192a01 to 98a237d Compare June 7, 2023 12:03
@coveralls
Copy link

Coverage Status

coverage: 79.914% (+0.03%) from 79.885% when pulling 98a237d on lzhecheng:dualstack-nsg into e5a3523 on kubernetes-sigs:master.

@lzhecheng
Copy link
Contributor Author

/retest

@lzhecheng lzhecheng force-pushed the dualstack-nsg branch 2 times, most recently from e02069b to 4ca9b1e Compare June 8, 2023 13:03
@@ -197,7 +197,7 @@ var _ = Describe("Azure node resources", Label(utils.TestSuiteLabelNode), func()

utils.Logf("getting all NICs of VMSS VMs")
for _, vmssVM := range vmssVMs {
utils.Logf("Checking %d VMSS VM %q", vmssVM.Name)
utils.Logf("Checking %d VMSS VM %q", *vmssVM.Name)
Copy link
Member

Choose a reason for hiding this comment

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

2 args?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -989,7 +989,9 @@ func (fs *FlexScaleSet) ensureBackendPoolDeletedFromNode(vmssFlexVMNameMap map[s
nics[nicName] = nic
}
}
nicUpdaterLock := "nicUpdaterLock"
Copy link
Member

Choose a reason for hiding this comment

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

+1 atomic.Store() may be better than lock?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will update in the other PR and rebase.

klog.V(2).Infof("IPv6 is not supported for private link service, skip reconcilePrivateLinkService for service(%s)", serviceName)
return nil
}
if !isDualStack {
Copy link
Member

Choose a reason for hiding this comment

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

We don't need this if at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@@ -135,10 +135,10 @@ func (bc *backendPoolTypeNodeIPConfig) CleanupVMSetFromBackendPoolByCondition(sl
})
}
if v4Enabled {
findBackendpoolToBeDeleted(false)
findBackendpoolToBeDeleted(IsIPv4)
Copy link
Contributor

Choose a reason for hiding this comment

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

can we call findBackendpoolToBeDeleted directly?

@@ -296,8 +296,8 @@ func getBackendPoolName(clusterName string, isIPv6 bool) string {
// getBackendPoolNames returns the IPv4 and IPv6 backend pool names.
func getBackendPoolNames(clusterName string) map[bool]string {
return map[bool]string{
false: getBackendPoolName(clusterName, false),
true: getBackendPoolName(clusterName, true),
IsIPv4: getBackendPoolName(clusterName, IsIPv4),
Copy link
Contributor

Choose a reason for hiding this comment

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

can we define a enum type for IsIPv4 and IsIPv6? I'm not sure these two variables are mutually exclusive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IsIPv4 is actually NotIPv6, so they are mutually exclusive.

@lzhecheng
Copy link
Contributor Author

/test pull-cloud-provider-azure-e2e-ccm-ipv6-capz
/test pull-cloud-provider-azure-e2e-ccm-ipv6-vmss-capz
/test pull-cloud-provider-azure-e2e-ccm-dualstack-capz
/test pull-cloud-provider-azure-e2e-ccm-dualstack-vmss-capz

@lzhecheng
Copy link
Contributor Author

/test pull-cloud-provider-azure-e2e-ccm-capz

@@ -197,7 +197,7 @@ var _ = Describe("Azure node resources", Label(utils.TestSuiteLabelNode), func()

utils.Logf("getting all NICs of VMSS VMs")
for _, vmssVM := range vmssVMs {
utils.Logf("Checking %d VMSS VM %q", vmssVM.Name)
utils.Logf("Checking VMSS VM %q", *vmssVM.Name)
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we safely refer to this variable securely by invoking to. String?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@lzhecheng
Copy link
Contributor Author

/retest

@@ -68,10 +68,10 @@ func (az *Cloud) existsPip(clusterName string, service *v1.Service) bool {
return existingPip
}

if v4Enabled && !existsPipSingleStack(false) {
if v4Enabled && !existsPipSingleStack(IsIPv4) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think a better name would be IPVersionIPv4. IsIPv4 sounds like a variable, not a constant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

// Before DualStack support, old logic takes the first ingress IP as non-additional one
// and the second one as additional one. With DualStack support, the second IP may be
// the IP of another IP family so the new logic returns two variables.
func (az *Cloud) getServiceLoadBalancerStatus(service *v1.Service, lb *network.LoadBalancer) (status *v1.LoadBalancerStatus, lbIPsNoAdditionalPIPs []string, fipConfigs []*network.FrontendIPConfiguration, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is noAdditional means primary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It means compared to ingress IPs in status, lbIPsNoAdditionalPIPs doesn't include those IPs from service.beta.kubernetes.io/azure-additional-public-ips annotation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will it be better to replace to primary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, NoAdditional seems too straightforward. Replaced.

@@ -34,6 +34,11 @@ import (
"sigs.k8s.io/cloud-provider-azure/pkg/consts"
)

const (
IsIPv6 bool = true
Copy link
Contributor

Choose a reason for hiding this comment

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

move to consts.go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

@lzhecheng lzhecheng force-pushed the dualstack-nsg branch 2 times, most recently from 53d35e2 to 813fd2f Compare June 19, 2023 10:01
Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>
* Support NSG and clean LBs for dualstack
* Support related UTs for dualstack
* Refactor

Signed-off-by: Zhecheng Li <zhechengli@microsoft.com>
@nilo19
Copy link
Contributor

nilo19 commented Jun 21, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 21, 2023
@k8s-ci-robot k8s-ci-robot merged commit 12b808f into kubernetes-sigs:master Jun 21, 2023
21 checks passed
@lzhecheng lzhecheng deleted the dualstack-nsg branch June 21, 2023 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. 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. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants