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

Configure TemplateLB with all host addresses #3557

Merged
merged 4 commits into from May 15, 2023

Conversation

zeeke
Copy link
Contributor

@zeeke zeeke commented Apr 28, 2023

- What this PR does and why is it needed

This PR makes NodePort services with ExternalClusterPolicy=Cluster to be served
on every host address.
It's meant to be a continuation of

- Special notes for reviewers

cc @dceara

- How to verify it

- Description for the changelog

@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch 5 times, most recently from 7d8ff81 to 640496b Compare April 29, 2023 10:49
@trozet trozet requested a review from dceara May 1, 2023 14:45
Copy link
Member

@tssurya tssurya left a comment

Choose a reason for hiding this comment

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

main logic lgtm, some suggestions and questions

test/e2e/e2e.go Outdated
@@ -2276,18 +2276,26 @@ var _ = ginkgo.Describe("e2e ingress traffic validation", func() {
// This test verifies a NodePort service is reachable on manually added IP addresses.
ginkgo.It("for NodePort services", func() {
Copy link
Member

Choose a reason for hiding this comment

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

e2e tests for services belong in services.go file (I know we have some older tests lying around in e2e.go but goal is to have newer tests in the specific file created for services tests)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the test to service.go

Copy link
Member

Choose a reason for hiding this comment

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

may I ask why the tests in the first PR didn't catch this? I know @dceara mentioned something to me but not sure I got the full picture...basically how was the logic being done in the first PR versus this one? If we hadn't added templating for multiple nodeIP's how was it passing in the first PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The test added in #3328 checks services with ETP=local, that AFAIU is implemented without Templates.

func makeLBNodeIPTemplateName(family corev1.IPFamily) string {
return fmt.Sprintf("%s_%v", LBVipNodeTemplate, family)
func makeLBNodeIPTemplateNamePrefix(family corev1.IPFamily) string {
return fmt.Sprintf("%s_%v_", LBVipNodeTemplate, family)
}

// isLBNodeIPTemplateName returns true if 'name' is the node IP template name
// for any IP family.
func isLBNodeIPTemplateName(name string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

we should change this to isLBNodeIPTemplateNamePrefix ? and update the function description as well to say we now search for prefix

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 the description. I left the function name as is, as it doesn't check if the input string is a prefix. It returns true if the passed name is the name of a NodeIP template. Does it sound good?

@@ -180,15 +175,15 @@ func svcCreateOrUpdateTemplateVar(nbClient libovsdbclient.Client, templateVars [
}

// makeLBNodeIPTemplateName creates a template name for the node IP (per family)
func makeLBNodeIPTemplateName(family corev1.IPFamily) string {
return fmt.Sprintf("%s_%v", LBVipNodeTemplate, family)
func makeLBNodeIPTemplateNamePrefix(family corev1.IPFamily) string {
Copy link
Member

Choose a reason for hiding this comment

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

nit: update the func description to say we are creating a template prefix name for the nodeIP

type NodeIPsTemplates struct {
ipFamily corev1.IPFamily
templateValues []*chassisTemplateValue
chassisIDtoIPCount map[string]int
Copy link
Member

Choose a reason for hiding this comment

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

Is this tracking the number of nodeIPs per chassis?

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, going to rename it

type chassisTemplateValue struct {
templateName string
chassisID string
value string
Copy link
Member

Choose a reason for hiding this comment

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

what is this value here within the chassisTemplateValue ? Please add some doc strings for this one, et.too.many.value usages....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed and documented. Let me know if it's clear

@@ -215,3 +210,72 @@ func getTemplatesFromRulesTargets(rules []LBRule) TemplateMap {
}
return templates
}

// NodeIPTemplates maintains templates variables for many IP addresses per node,
// creating template variables in the for NODEIP_IPv4_0, NODEIP_IPv4_1, NODEIP_IPv4_2, ...
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
// creating template variables in the for NODEIP_IPv4_0, NODEIP_IPv4_1, NODEIP_IPv4_2, ...
// creating template variables for NODEIP_IPv4_0, NODEIP_IPv4_1, NODEIP_IPv4_2, ...

?

c.nodeIPv4Template.Value[node.chassisID] = ipv4.String()
ips, err := util.MatchIPFamily(false, nodeInfo.hostAddresses)
if err != nil {
klog.Warningf("Error while searching for IPv4 host addresses: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

we should probably include the nodeInfo.name in the warning message to make it easier to map it to the node

c.nodeIPv6Template.Value[node.chassisID] = ipv6.String()
ips, err := util.MatchIPFamily(true, nodeInfo.hostAddresses)
if err != nil {
klog.Warningf("Error while searching for IPv6 host addresses: %v", err)
Copy link
Member

Choose a reason for hiding this comment

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

ditto: include nodeName in warning message

@@ -510,6 +510,120 @@ func TestSyncServices(t *testing.T) {
}
}

func Test_ETPCluster_NodePort_Service_WithMultipleIPAddresses(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

thank you for the tests++ nit: suggestion to swap some into IPV6 addresses to cover those bits as well but I won't hold the PR for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a commit to convert that test to dualstack:
8a973fa

Test code becomes a little bit more complicated. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

I am good with this thanks @zeeke !

@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch from 640496b to 92da78f Compare May 5, 2023 11:55
@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch from 92da78f to 3585b2f Compare May 5, 2023 12:22
@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch 3 times, most recently from 99a1050 to 3626614 Compare May 5, 2023 18:05
@coveralls
Copy link

coveralls commented May 5, 2023

Coverage Status

Coverage: 53.145% (+0.09%) from 53.05% when pulling ed9a280 on zeeke:node-port-svc-on-secondary-ip-rework into 7f008bd on ovn-org:master.

@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch from 3626614 to ed9a280 Compare May 8, 2023 07:44
@@ -0,0 +1,79 @@
package services
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding tests!

test/e2e/e2e.go Outdated Show resolved Hide resolved
test/e2e/e2e.go Outdated Show resolved Hide resolved
// AddIP adds a template variable for the specified chassis and ip address.
func (n *NodeIPsTemplates) AddIP(chassisID string, ip net.IP) {

var i int = -1
Copy link
Member

Choose a reason for hiding this comment

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

hmm I see this part of code also changed since I previously did a review, not a fan of the starting with i = -1 just using that variable to get the total number of templates we have for the node a.k.a the nodeIPs..., if like @dceara mentions we can leverage the length and figure that out, let's do that...seems cleaner?

@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch from ed9a280 to a1accc1 Compare May 9, 2023 09:40
dceara
dceara previously approved these changes May 10, 2023
Copy link
Contributor

@dceara dceara left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

framework.Failf("failed to add new Addresses to node %s: %v", node.Name, err)
}

defer runCommand(containerRuntime, "exec", node.Name, "ip", "addr", "delete", newIP+"/32", "dev", "breth0")
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: fail the test id this fails

@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch 2 times, most recently from a385454 to d6b0d8d Compare May 10, 2023 15:01
tssurya
tssurya previously approved these changes May 10, 2023
Copy link
Member

@tssurya tssurya left a comment

Choose a reason for hiding this comment

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

/lgtm
thanks @zeeke

@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch from d6b0d8d to 16d5df1 Compare May 11, 2023 06:57
zeeke added 3 commits May 11, 2023 10:29
TemplateLB variables for node IP addresses have to
support multiple IP noda address, hence the variables
are in the format of NODE_IPv4_0, NODE_IPv4_1, NODE_IPv4_2, ...
Struct `NodeIPsTemplates` manage the template variables
for multiple nodes that may have different number of IP addresses each.

Add unit and e2e tests on TemplateLBs with multiple IP addresses.

Refs: ovn-org#3328

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
Make `Test_ETPCluster_NodePort_Service_WithMultipleIPAddresses`
use v4+v6 IP addresses.

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
The test about NodePort services that are reachable on every
host IP address should reside in the Service suite.

Signed-off-by: Andrea Panattoni <apanatto@redhat.com>
@zeeke zeeke force-pushed the node-port-svc-on-secondary-ip-rework branch from 16d5df1 to 454119c Compare May 11, 2023 08:29
@trozet
Copy link
Contributor

trozet commented May 15, 2023

Flake:
[Fail] Load Balancer Service Tests with MetalLB [It] Should ensure load balancer service works with pmtu
/home/runner/work/ovn-kubernetes/ovn-kubernetes/test/e2e/service.go:885

[Fail] Load Balancer Service Tests with MetalLB [It] Should ensure load balancer service works with pmtu

https://github.com/ovn-org/ovn-kubernetes/actions/runs/4981960698/jobs/8917595516?pr=3557

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants