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

Change behaviour gateway addressess override in Link command #11564

Merged
merged 2 commits into from Nov 14, 2023

Conversation

mateiidavid
Copy link
Member

When linking two clusters, a --gateway-addresses override can be passed to the command. If applied, the override populates the Link resource with a set of addresses received from the flag, instead of reading them from Linkerd's Gateway LoadBalancer service. Currently, the override is used only when the LoadBalancer service does not exist (or does not contain any IPs).

An override should take precedence over default behaviour. As it stands, the user experience is confusing; it can also make manual testing for changes hard (when an override has to be passed) and it can inhibit users from passing in a static IP or DNS addresses to avoid relying on dynamic IPs in the LoadBalancer service.

This change makes the override behave as expected.

Manual QA

Before:

# `linkerd mc link --gateway-addresses="headless-test.default.svc.cluster.loca
l" `
apiVersion: multicluster.linkerd.io/v1alpha1
kind: Link
metadata:
  name: target
  namespace: linkerd-multicluster
spec:
  gatewayAddress: 192.168.224.4

After:

# k get link -n linkerd-multicluster target -o json | jq .spec.gatewayAddress
"headless-test.default.svc.cluster.local"

When linking two clusters, a `--gateway-addresses` override can be
passed to the command. If applied, the override populates the Link
resource with a set of addresses received from the flag, instead of
reading them from Linkerd's Gateway LoadBalancer service. Currently, the
override is used only when the LoadBalancer service does not exist (or
does not contain any IPs).

An override should take precedence over default behaviour. As it stands,
the user experience is confusing; it can also make manual testing for
changes hard (when an override has to be passed) and it can inhibit
users from passing in a static IP or DNS addresses to avoid relying on
dynamic IPs in the LoadBalancer service.

This change makes the override behave as expected.

Signed-off-by: Matei David <matei@buoyant.io>
@mateiidavid mateiidavid requested a review from a team as a code owner November 3, 2023 11:37
Copy link
Member

@alpeb alpeb left a comment

Choose a reason for hiding this comment

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

How about making this extra-clearer by extracting this logic into a helper function func getGatewayAddresses(gateway *corev1.Service, opts *linkOptions) (string, error) which would immediately return opts.gatewayAddresses if not empty, followed by the other conditions that no longer have to take into account that option?

@mateiidavid
Copy link
Member Author

@alpeb sure! Think there's potential for a clean up here and the suggestion sounds good 👍🏻

@@ -247,7 +247,7 @@ A full list of configurable values can be found at https://github.com/linkerd/li
if len(gwAddresses) == 0 && opts.gatewayAddresses == "" {
Copy link
Member

Choose a reason for hiding this comment

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

an alternative way to structure this for clarity:

if opts.gatewayAddresses != "" {
  gatewayAddresses = opts.gatewayAddresses
} else if len(gwAddresses) > 0 {
  gatewayAddresses = strings.Join(gwAddresses, ",")
} else {
  return fmt.Errorf(...)
}

This condenses the error handling and gateway population into the same if-else block and makes the prescience clearer: opt then LB then error.

Signed-off-by: Matei David <matei@buoyant.io>
@mateiidavid
Copy link
Member Author

Thanks both. Tried a few things, including extracting some of the logic into a separate function. In the end, took Alex's suggestion since it's a relatively simple conditional. Took it a bit further and eliminated gatewayAddresses as a temp variable, we ultimately move that into the link anyway.

# IP of the gateway service
:; k get service -n linkerd-multicluster --context=k3d-target linkerd-gateway -o json | jq .status.loadBalancer.ingress[0].ip
"192.168.224.4"

# Override doesn't work
:; linkerd --context=k3d-target mc link --cluster-name target --api-server-address="https://192.168.224.4:6443" --gateway-addresses="head
less-test.default.svc.cluster.local" | rg 'gatewayAddress'
  gatewayAddress: 192.168.224.4

# Now it does
:; bin/linkerd --context=k3d-target mc link --cluster-name target --api-server-address="https://192.168.224.4:6443" --gateway-addresses="
headless-test.default.svc.cluster.local" | rg 'gatewayAddress'
  gatewayAddress: headless-test.default.svc.cluster.local

# No external IP on gateway service or override => error
:; bin/linkerd --context=k3d-target mc link --cluster-name target --api-server-address="https://192.168.224.4:6443"
Error: Gateway linkerd-gateway.linkerd-multicluster has no ingress addresses

@mateiidavid mateiidavid merged commit f075cb3 into main Nov 14, 2023
35 checks passed
@mateiidavid mateiidavid deleted the matei/multicluster-addresses branch November 14, 2023 18:42
@adleong adleong mentioned this pull request Nov 16, 2023
adleong added a commit that referenced this pull request Nov 17, 2023
This edge release fixes a bug where Linkerd could cause EOF errors during bursts
of TCP connections.

* Fixed a bug where the `linkerd multicluster link` command's
  `--gateway-addresses` flag was not respected when a remote gateway exists
  ([#11564])
* proxy: Increased DEFAULT_OUTBOUND_TCP_QUEUE_CAPACITY to prevent EOF errors
  during bursts of TCP connections

[#11564]: #11564

Signed-off-by: Alex Leong <alex@buoyant.io>
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

3 participants