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

Support multiple IPPools in the namespace #4777

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

cnvergence
Copy link
Contributor

@cnvergence cnvergence commented Nov 28, 2024

Pull Request

What type of this PR

Examples of user facing changes:

  • Features
  • Bug fixes
  • Docs
  • Tests

While reproducing issue #4687 (comment)
I have found that when user have multiple IPPools in the single namespace, pods without ippool annotation won’t be able to pick up a correct address.

Which issue(s) this PR fixes

Fixes #4687

@cnvergence cnvergence marked this pull request as ready for review December 4, 2024 17:58
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. feature New network feature test automation tests labels Dec 4, 2024
@coveralls
Copy link

coveralls commented Dec 4, 2024

Pull Request Test Coverage Report for Build 12298070287

Details

  • 0 of 19 (0.0%) changed or added relevant lines in 2 files are covered.
  • 3 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.004%) to 21.899%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/controller/namespace.go 0 9 0.0%
pkg/controller/pod.go 0 10 0.0%
Files with Coverage Reduction New Missed Lines %
pkg/controller/namespace.go 1 0.0%
pkg/ovs/ovn-nb-bfd.go 2 61.61%
Totals Coverage Status
Change from base Build 12290974777: -0.004%
Covered Lines: 10183
Relevant Lines: 46499

💛 - Coveralls

@dosubot dosubot bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Dec 6, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Dec 11, 2024
@cnvergence cnvergence force-pushed the fix-ipampools-ns branch 4 times, most recently from db03de0 to 178f7c2 Compare December 12, 2024 13:36
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
Signed-off-by: Karol Szwaj <[email protected]>
@cnvergence
Copy link
Contributor Author

PTAL @zhangzujian

@@ -509,4 +509,56 @@ var _ = framework.Describe("[group:ipam]", func() {
deploy = deployClient.PatchSync(deploy, patchedDeploy)
checkFn()
})

framework.ConformanceIt("should allocate right IPs for the statefulset when there are multiple IP Pools added to its namespace", func() {
Copy link
Member

@zhangzujian zhangzujian Dec 13, 2024

Choose a reason for hiding this comment

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

Let's skip this test case for versions < v1.14 by using f.SkipVersionPriorTo(1, 14, "some message...")

Comment on lines +525 to +526
testSubnet := framework.MakeSubnet(testSubnetName, "", testCidr, "", "", "", nil, nil, []string{namespaceName})
subnetClient.CreateSync(testSubnet)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
testSubnet := framework.MakeSubnet(testSubnetName, "", testCidr, "", "", "", nil, nil, []string{namespaceName})
subnetClient.CreateSync(testSubnet)
testSubnet := framework.MakeSubnet(testSubnetName, "", testCidr, "", "", "", nil, nil, []string{namespaceName})
ginkgo.DeferCleanup(func() {
ginkgo.By("Deleting subnet " + testSubnetName)
subnetClient.DeleteSync(testSubnetName)
})
subnetClient.CreateSync(testSubnet)

Let's use ginkgo.DeferCleanup() to ensure test resources are cleaned up.

Comment on lines +554 to +562
ginkgo.By("Deleting statefulset " + testStsName)
stsClient.DeleteSync(testStsName)

ginkgo.By("Deleting ippools")
ippoolClient.DeleteSync(testIPPool1Name)
ippoolClient.DeleteSync(testIPPool2Name)

ginkgo.By("Deleting subnet " + testSubnetName)
subnetClient.DeleteSync(testSubnetName)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ginkgo.By("Deleting statefulset " + testStsName)
stsClient.DeleteSync(testStsName)
ginkgo.By("Deleting ippools")
ippoolClient.DeleteSync(testIPPool1Name)
ippoolClient.DeleteSync(testIPPool2Name)
ginkgo.By("Deleting subnet " + testSubnetName)
subnetClient.DeleteSync(testSubnetName)

Since we are using ginkgo.DeferCleanup(), there is no need to delete the resources here.

Comment on lines +519 to +521
testSubnetName := "ip-pool-subnet2"
testIPPool1Name := "ip-pool1"
testIPPool2Name := "ip-pool2"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
testSubnetName := "ip-pool-subnet2"
testIPPool1Name := "ip-pool1"
testIPPool2Name := "ip-pool2"
testSubnetName := "ip-pool-subnet2" + framework.RandomSuffix()
testIPPool1Name := "ip-pool1" + framework.RandomSuffix()
testIPPool2Name := "ip-pool2" + framework.RandomSuffix()

Subnet and ippool are cluster wide resources, we need to add a suffix to them.

replicas := 1
ipsCount := 12
ipsRange1 := framework.RandomIPPool(cidr, ipsCount)
ipsRange2 := framework.RandomIPPool(cidr, ipsCount)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ipsRange2 := framework.RandomIPPool(cidr, ipsCount)
ipsRange2 := framework.RandomIPPool(testCidr, ipsCount)

Should be testCidr here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New network feature size:M This PR changes 30-99 lines, ignoring generated files. test automation tests
Projects
None yet
3 participants