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

fix: listener on IPv6 first cluster #4573

Closed
wants to merge 2 commits into from

Conversation

zirain
Copy link
Contributor

@zirain zirain commented Oct 30, 2024

fix: #4565
xref: #4572
Separate from : #4550

  • EG controller will detect the cluster is IPv6 or IPv4 first base on pod IP.
  • controller will change the default listener socket address base on that, use :: instead of 0.0.0.0 when IPv6 first.

@zirain zirain requested a review from a team as a code owner October 30, 2024 07:35
Copy link

codecov bot commented Oct 30, 2024

Codecov Report

Attention: Patch coverage is 80.95238% with 16 lines in your changes missing coverage. Please review.

Project coverage is 65.54%. Comparing base (5698e88) to head (1c4d283).

Files with missing lines Patch % Lines
internal/utils/net/ip.go 73.68% 4 Missing and 1 partial ⚠️
internal/xds/translator/listener.go 85.18% 3 Missing and 1 partial ⚠️
internal/gatewayapi/listener.go 57.14% 2 Missing and 1 partial ⚠️
internal/cmd/envoy/shutdown_manager.go 0.00% 2 Missing ⚠️
internal/gatewayapi/runner/runner.go 0.00% 1 Missing ⚠️
internal/infrastructure/host/proxy_infra.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4573      +/-   ##
==========================================
+ Coverage   65.50%   65.54%   +0.04%     
==========================================
  Files         211      212       +1     
  Lines       31945    31988      +43     
==========================================
+ Hits        20925    20967      +42     
- Misses       9774     9777       +3     
+ Partials     1246     1244       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zirain zirain mentioned this pull request Oct 31, 2024
7 tasks
@zirain zirain force-pushed the ipv6-listener branch 3 times, most recently from 00e8a5c to c266511 Compare October 31, 2024 11:55
if resp, err := http.Post(fmt.Sprintf("http://%s:%d/%s",
bootstrap.EnvoyAdminAddress, bootstrap.EnvoyAdminPort, path), "application/json", nil); err != nil {
bootstrap.AdminAddress(egv1a1.IPv4), bootstrap.EnvoyAdminPort, path), "application/json", nil); err != nil {
Copy link
Contributor Author

@zirain zirain Oct 31, 2024

Choose a reason for hiding this comment

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

this may not right, what about change it to localhost? cc @arkodg @zhaohuabing

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to localhost, good idea

Copy link
Member

Choose a reason for hiding this comment

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

+1 localhost make things easier

@zirain zirain added the area/IPv6 IPv6 related issues label Oct 31, 2024
}

func PreferIPFamily(ipv6First bool, envoyProxy *egv1a1.EnvoyProxy) egv1a1.IPFamily {
if ipv6First {
Copy link
Member

@zhaohuabing zhaohuabing Nov 1, 2024

Choose a reason for hiding this comment

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

To align with the IPFamily API docs, EG should default to IPv4.

	// IPFamily specifies the IP family for the EnvoyProxy fleet.
	// This setting only affects the Gateway listener port and does not impact
	// other aspects of the Envoy proxy configuration.
	// If not specified, the system will operate as follows:
	// - It defaults to IPv4 only.
	// - IPv6 and dual-stack environments are not supported in this default configuration.
	// Note: To enable IPv6 or dual-stack functionality, explicit configuration is required.
	// +kubebuilder:validation:Enum=IPv4;IPv6;DualStack
	// +optional
	IPFamily *IPFamily `json:"ipFamily,omitempty"`

Or do we want to change to:

Default to the IP family of the POD IP of the Envoy Proxy/Envoy Gateway?

This would have EG attempt to infer user's intented IP Family for the listening port of the Envoy proxy, which might not always be accurate.

Should we always default to IPv4 and require users to explicitly specify IPv6 if desired? It will make the IPFamily choice more explicit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we always default to IPv4 and require users to explicitly specify IPv6 if desired? It will make the IPFamily choice more explicit.

this will make it's hard to use on IPv6 first cluster.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, this approach requires one more IPFamily setting for users who want to use IPv6.

But if we make it implicit, "Default to the IP family of the POD IP of the Envoy Proxy/Envoy Gateway" may be challenging to clearly explain in the EG doc.

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, we should do that.

@@ -146,36 +147,6 @@ func originalIPDetectionExtensions(clientIPDetection *ir.ClientIPDetectionSettin
return extensionConfig
}

func setAddressByIPFamily(socketAddress *corev3.SocketAddress, ipFamily *ir.IPFamily, port uint32) []*listenerv3.AdditionalAddress {
Copy link
Contributor

Choose a reason for hiding this comment

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

why does this function need to change ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Before this function change socketAddress and return additionalAddress in the same time.


defaultSdsTrustedCAPath = "/sds/xds-trusted-ca.json"
defaultSdsCertificatePath = "/sds/xds-certificate.json"
)

func AdminAddress(family egv1a1.IPFamily) string {
if family == egv1a1.IPv6 {
Copy link
Contributor

Choose a reason for hiding this comment

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

will localhost here work ?

Copy link
Contributor Author

@zirain zirain Nov 2, 2024

Choose a reason for hiding this comment

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

return error malformed IP address: localhost

return envoyAdminAddress
}

func readinessAddress(family egv1a1.IPFamily) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

imo just the changes in this file should be enough to support pure IPv6 case as well as dual stack case, wdyt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

need changes around dynamic istener for IPv6 first/pure cluster.

Signed-off-by: zirain <[email protected]>
@zirain zirain closed this Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/IPv6 IPv6 related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IPv6 dual-stack not working on IPv6 first clusters due to IPv4 fixed listeners
3 participants