-
Notifications
You must be signed in to change notification settings - Fork 280
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
Remove shared nsg rule immediately when no destinations prefixes are left #3787
Remove shared nsg rule immediately when no destinations prefixes are left #3787
Conversation
✅ Deploy Preview for kubernetes-sigs-cloud-provide-azure canceled.
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: MartinForReal 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 |
@@ -3785,6 +3785,52 @@ func TestReconcileSecurityGroup(t *testing.T) { | |||
}, | |||
}, | |||
}, | |||
{ |
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.
Do we have a test case where the sg rule should be deleted completely?
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.
Please refer to
cloud-provider-azure/tests/e2e/network/network_security_group.go
Lines 143 to 191 in 3f6d95e
It("should support service annotation `service.beta.kubernetes.io/azure-shared-securityrule`", func(ctx SpecContext) { | |
By("Exposing two services with shared security rule") | |
annotation := map[string]string{ | |
consts.ServiceAnnotationSharedSecurityRule: "true", | |
} | |
ips1 := createAndExposeDefaultServiceWithAnnotation(cs, tc.IPFamily, serviceName, ns.Name, labels, annotation, ports) | |
defer func() { | |
err := utils.DeleteService(cs, ns.Name, serviceName) | |
Expect(err).NotTo(HaveOccurred()) | |
}() | |
serviceName2 := serviceName + "-share" | |
ips2 := createAndExposeDefaultServiceWithAnnotation(cs, tc.IPFamily, serviceName2, ns.Name, labels, annotation, ports) | |
defer func() { | |
By("Cleaning up") | |
err := utils.DeleteService(cs, ns.Name, serviceName2) | |
Expect(err).NotTo(HaveOccurred()) | |
}() | |
By("Validate shared security rule exists") | |
port := fmt.Sprintf("%d", serverPort) | |
nsgs, err := tc.GetClusterSecurityGroups() | |
Expect(err).NotTo(HaveOccurred()) | |
ipList := append(ips1, ips2...) | |
Expect(validateSharedSecurityRuleExists(nsgs, ipList, port)).To(BeTrue(), "Security rule for service %s not exists", serviceName) | |
By("Validate automatically adjust or delete the rule, when service is deleted") | |
Expect(utils.DeleteService(cs, ns.Name, serviceName)).NotTo(HaveOccurred()) | |
ipList = ips2 | |
Eventually(func() (bool, error) { | |
nsgs, err = tc.GetClusterSecurityGroups() | |
if err != nil { | |
return false, err | |
} | |
return validateSharedSecurityRuleExists(nsgs, ips2, port) && !validateSharedSecurityRuleExists(nsgs, ips1, port), nil | |
}).WithContext(ctx).Should(BeTrue(), "Security rule should be modified to only contain service %s", serviceName2) | |
Expect(utils.DeleteService(cs, ns.Name, serviceName2)).NotTo(HaveOccurred()) | |
Eventually(func() (bool, error) { | |
nsgs, err := tc.GetClusterSecurityGroups() | |
if err != nil { | |
return false, err | |
} | |
return validateSharedSecurityRuleExists(nsgs, ipList, port), nil | |
}).WithContext(ctx).Should(BeFalse(), "Fail to automatically delete the shared security rule") | |
}) |
Signed-off-by: MartinForReal <fanshangxiang@gmail.com>
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
/retest |
/cherrypick release-1.27 |
/cherrypick release-1.26 |
/cherrypick release-1.25 |
/cherrypick release-1.24 |
@MartinForReal: new pull request created: #3797 In response to this:
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. |
@MartinForReal: new pull request created: #3798 In response to this:
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. |
@MartinForReal: new pull request created: #3799 In response to this:
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. |
@MartinForReal: new pull request created: #3800 In response to this:
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. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
Remove shared nsg rule immediately when no destinations left
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: