-
Notifications
You must be signed in to change notification settings - Fork 373
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
Add IPv4/v6 dual stack support in Flow aggregator #1962
Conversation
/test-ipv6-only-e2e |
Codecov Report
@@ Coverage Diff @@
## main #1962 +/- ##
==========================================
+ Coverage 65.37% 67.08% +1.70%
==========================================
Files 197 197
Lines 17217 18014 +797
==========================================
+ Hits 11256 12085 +829
+ Misses 4786 4708 -78
- Partials 1175 1221 +46
Flags with carried forward coverage won't be shown. Click here to find out more.
|
b43f752
to
958314b
Compare
/test-all Is the "Draft status" still intended? |
Hi Srikar, yes it's still under development. I found the dual cluster environment on jenkins is different from my local setup, and I'm still debugging on it. |
0cde7a5
to
543e90a
Compare
/test-ipv6-only-e2e |
/test-all |
9df5a8c
to
d92cc41
Compare
/test-all |
func skipIfDualStackCluster(tb testing.TB) { | ||
if clusterInfo.podV6NetworkCIDR != "" && clusterInfo.podV4NetworkCIDR != "" { | ||
tb.Skipf("Skipping test as it is not supported in dual stack cluster") | ||
} | ||
} |
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.
Keep it for future use?
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
} | ||
} | ||
|
||
func createSvcRunTests(t *testing.T, data *TestData, podAIP *PodIPs, podBIP *PodIPs, podCIP *PodIPs, isIPv6 bool) { |
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.
Separate out createServices function and runTests function for better readability
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.
Thanks, addressed.
third_party/proxy/meta_proxier.go
Outdated
@@ -160,12 +161,12 @@ func (proxier *metaProxier) OnEndpointsSynced() { | |||
} | |||
|
|||
func (proxier *metaProxier) GetServiceByIP(serviceStr string) (ServicePortName, bool) { | |||
if utilnet.IsIPv6String(serviceStr) { | |||
// Format of serviceStr is fmt.Sprintf("%s:%d/%s", clusterIP, svcPort, protocol), so IPv6 serviceStr has more than 3 colons. | |||
if strings.Count(serviceStr, ":") >= 3 { |
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.
Check looks somewhat arbitrary. Can we parse the string with last colon as the separator and use the IP?
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.
Thanks, addressed.
third_party/proxy/meta_proxier.go
Outdated
@@ -160,12 +161,12 @@ func (proxier *metaProxier) OnEndpointsSynced() { | |||
} | |||
|
|||
func (proxier *metaProxier) GetServiceByIP(serviceStr string) (ServicePortName, bool) { |
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.
Hi @jianjuns ,
GetServiceByIP
is a method in Proxier interface defined in pkg/third_party/proxy
This was originally defined in pkg/agent/proxy but moved to third-party pkg. This is currently used by Flow Exporter running in Agent and no one else uses it.
Therefore, I think it should follow the placement of GetServiceFlowKeys
method and placed in pkg/agent/proxy. Do you agree?
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.
That sounds good to me.
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.
Thanks Srikar and Jianjun, moved the GetServiceByIP under pkg/agent/proxy and removed it from Provider interface in third_party/proxy.
9a6fa10
to
6901b39
Compare
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.
Will there be any changes on Kibana dashboard for dual-stack clusters?
Hi Srikar, Kibana dashboard has supported dual stack environment in the previous IPv6 support PR. |
/test-all |
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
pkg/agent/proxy/proxier.go
Outdated
@@ -53,6 +54,9 @@ type Proxier interface { | |||
// flows and the OVS group IDs for a Service. False is returned if the | |||
// Service is not found. | |||
GetServiceFlowKeys(serviceName, namespace string) ([]string, []binding.GroupIDType, bool) | |||
// GetServiceByIP returns the ServicePortName struct of giving serviceString(ClusterIP:Port/Proto). |
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.
"of giving"? do you mean "for the given"?
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.
Thanks, addressed.
pkg/agent/proxy/proxier.go
Outdated
@@ -53,6 +54,9 @@ type Proxier interface { | |||
// flows and the OVS group IDs for a Service. False is returned if the | |||
// Service is not found. | |||
GetServiceFlowKeys(serviceName, namespace string) ([]string, []binding.GroupIDType, bool) | |||
// GetServiceByIP returns the ServicePortName struct of giving serviceString(ClusterIP:Port/Proto). | |||
// False is returned if the serviceString is not existed in serviceStringMap. |
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.
s/is not existed/does not exist
or
s/is not existed/is not found
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.
Thanks, addressed.
pkg/agent/proxy/proxier.go
Outdated
@@ -639,6 +643,16 @@ func (p *metaProxierWrapper) GetServiceFlowKeys(serviceName, namespace string) ( | |||
return append(v4Flows, v6Flows...), append(v4Groups, v6Groups...), v4Found || v6Found | |||
} | |||
|
|||
func (p *metaProxierWrapper) GetServiceByIP(serviceStr string) (k8sproxy.ServicePortName, bool) { | |||
// Format of serviceStr is fmt.Sprintf("%s:%d/%s", clusterIP, svcPort, protocol). |
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.
that's a weird way of presenting it, why not:
// Format of serviceStr is <clusterIP>:<svcPort>/<protocol>
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
time.Sleep(3 * time.Second) | ||
|
||
runTests(t, data, podAIP, podBIP, podCIP, svcB, svcC, false) | ||
deletePerftestServices(data) |
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.
maybe use a defer
statement after the call to createPerftestServices
same below
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
if v6Enabled { | ||
svcB, svcC, err := createPerftestServices(data, true) | ||
if err != nil { | ||
t.Fatalf("Error when creating IPv6 perftest services: %v", err) | ||
} | ||
// Wait for the Service to be realized. | ||
time.Sleep(3 * time.Second) | ||
|
||
runTests(t, data, podAIP, podBIP, podCIP, svcB, svcC, true) | ||
deletePerftestServices(data) | ||
} |
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.
This looks like the exact same code as above. Maybe define a local function.
testHelper := func(isIPv6 bool) { ... }
if v4Enabled {
t.Logf("Running tests with IPv4 perftest service")
testHelper()
}
if v6Enabled
t.Logf("Running tests with IPv6 perftest service")
testHelper()
}
or even better, use subtests:
testHelper := func(t *testing.T, isIPv6 bool) { ... }
if v4Enabled {
t.Run("IPv4", func(t *testing.T) { testHelper(t, false) })
}
if v4Enabled {
t.Run("IPv6", func(t *testing.T) { testHelper(t, true) })
}
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.
Thanks, addressed it using subtests.
test/e2e/flowaggregator_test.go
Outdated
} | ||
} | ||
|
||
func runTests(t *testing.T, data *TestData, podAIP *PodIPs, podBIP *PodIPs, podCIP *PodIPs, svcB *corev1.Service, svcC *corev1.Service, isIPv6 bool) { |
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.
why is this helper method not in charge of creating the test resources (pods, services)? Why the need to pass them as parameters?
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.
Hi Antonin, after changing to use subtests, only pod IPs are passed as parameters to the testHelper method. The reason is that we would like to reuse perf pods in both IPv4 and IPv6 tests, while perf services need to be created for IPv4 and IPv6 differently.
third_party/proxy/types.go
Outdated
- Add Run(), GetServiceByIP() to Provider interface | ||
- Remove GetServiceByIP() from Provider interface |
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.
These list the changes compared to upstream...
you should edit the existing last bullet point, not add a new one
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.
Thanks, addressed.
7ce58b3
to
8efcf56
Compare
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.
some nits, otherwise LGTM
test/e2e/flowaggregator_test.go
Outdated
if err != nil { | ||
t.Fatalf("Error when setting up test: %v", err) | ||
} | ||
defer teardownTest(t, data) | ||
defer teardownFlowAggregator(t, data) | ||
|
||
podAIP, podBIP, podCIP, svcB, svcC, err := createPerftestPods(data, isIPv6) | ||
podAIP, podBIP, podCIP, err := createPerftestPods(data) |
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.
nit: looks like these should be named podAIPs
, podBIPs
, podCIPs
to match the rest of the code
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
if err != nil { | ||
t.Fatalf("Error when creating perftest pods and services: %v", err) | ||
t.Fatalf("Error when creating perftest pods: %v", err) |
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.
s/pods/Pods
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
func testHelper(t *testing.T, data *TestData, podAIP *PodIPs, podBIP *PodIPs, podCIP *PodIPs, isIPv6 bool) { | ||
svcB, svcC, err := createPerftestServices(data, isIPv6) | ||
if err != nil { | ||
t.Fatalf("Error when creating perftest services: %v", err) |
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.
s/services/Services
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
if err != nil { | ||
t.Fatalf("Error when creating perftest services: %v", err) | ||
} | ||
defer deletePerftestServices(data) |
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.
don't you want to log the error if there is one?
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
} | ||
podBIP, err = data.podWaitForIPs(defaultTimeout, "perftest-b", testNamespace) | ||
if err != nil { | ||
return nil, nil, nil, fmt.Errorf("Error when getting the perftest server Pod's IP: %v", err) |
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.
s/IP/IPs
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
if err != nil { | ||
return nil, nil, nil, nil, nil, fmt.Errorf("Error when getting the perftest server Pod's IP: %v", err) | ||
return nil, nil, fmt.Errorf("Error when creating perftest service: %v", err) |
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.
s/service/Service
same in every other place
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.
Thanks, addressed.
test/e2e/flowaggregator_test.go
Outdated
if err != nil { | ||
return nil, nil, nil, nil, nil, fmt.Errorf("Error when creating perftest service: %v", err) | ||
return nil, nil, nil, fmt.Errorf("Error when getting the perftest server Pod's IP: %v", err) |
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.
s/IP/IPs
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.
Thanks, addressed.
Fixed a bug in GetServiceByIP() function of dual-stack proxy and moved it under pkg/agent/proxy. Improved the e2e test of flow aggregator: for dual stack clusters, we will test services for both IPv4 and IPv6 clusterIP.
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
/test-all |
/test-e2e |
/test-ipv6-e2e |
All the reviews are done. Merging this. |
After investigation, we found that the e2e test failure in dual stack cluster of flow aggregator is because we couldn't retrieve the service info from antrea-agent-proxier for IPv6 service address in jenkins dual stack cluster.
In this commit, we fixed a bug in GetServiceByIP() function of dual-stack proxy.
Also, we improved the e2e test of flow aggregator: for dual stack clusters, we will test services for both IPv4 and IPv6 clusterIP.