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

L4 ILB - skip nodes from the non default network if multi subnet is t… #679

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mmamczur
Copy link
Contributor

…urned on.

This will just skip nodes that are not on the default network when creating the instance group.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 30, 2024
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If the repository mantainers determine this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Apr 30, 2024
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 30, 2024
@mmamczur
Copy link
Contributor Author

/assign @cezarygerard

@mmamczur mmamczur force-pushed the multi-subnet branch 3 times, most recently from e2f6c4c to c445469 Compare May 7, 2024 09:14
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 7, 2024
@mmamczur
Copy link
Contributor Author

/assign @code-elinka

@@ -254,6 +256,37 @@ func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v
return status, nil
}

Choose a reason for hiding this comment

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

can you add a comment why it is needed

Choose a reason for hiding this comment

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

Oh nvm, I see the comment in the usage

@code-elinka
Copy link

/approve

}
if !hasInstanceForNode(instances, nodes[2]) {
t.Errorf("expected n3 to be in instances but it contained %+v", instanceURLs)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

check also

if hasInstanceForNode(instances, nodes[3]) {
t.Errorf("unexpected n4 in instances ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

modified. there was a size check as well so it sort of checked it before

@cezarygerard
Copy link
Contributor

lgtm overall,

one comment on unit test

@mmamczur mmamczur force-pushed the multi-subnet branch 2 times, most recently from cc9d3d7 to 68ae610 Compare May 17, 2024 09:24
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 17, 2024
@cezarygerard
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 20, 2024
@cezarygerard
Copy link
Contributor

/approve

@cezarygerard
Copy link
Contributor

/assign cheftako

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 3, 2024
@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 3, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: cezarygerard, code-elinka, mmamczur
Once this PR has been reviewed and has the lgtm label, please ask for approval from cheftako. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 3, 2024
@mmamczur
Copy link
Contributor Author

mmamczur commented Jun 3, 2024

/assign @basantsa1989

@k8s-ci-robot
Copy link
Contributor

@mmamczur: GitHub didn't allow me to assign the following users: basantsa1989.

Note that only kubernetes members with read permissions, repo collaborators and people who have commented on this issue/PR can be assigned. Additionally, issues/PRs can only have 10 assignees at the same time.
For more information please see the contributor guide

In response to this:

/assign @basantsa1989

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@basantsa1989
Copy link
Contributor

/lgtm

@k8s-ci-robot
Copy link
Contributor

@basantsa1989: changing LGTM is restricted to collaborators

In response to this:

/lgtm

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

// Extract the subnet name from the URL.
// example: for `https://www.googleapis.com/compute/v1/projects/project/regions/us-central1/subnetworks/defaultSubnet`
// this will return `defaultSubnet`.
func subnetNameFromURL(url string) string {
Copy link
Member

Choose a reason for hiding this comment

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

This should have its own unit test.

This func should return an error instead of empty string if it fails to parse instead of eating the error.

@@ -254,6 +256,37 @@ func (g *Cloud) ensureInternalLoadBalancer(clusterName, clusterID string, svc *v
return status, nil
}

func filterOutNodesFromNonDefaultNetworks(nodes []*v1.Node, defaultSubnetURL string) []*v1.Node {
Copy link
Member

Choose a reason for hiding this comment

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

Can we change the name, it's very long and it's not specific to defaultSubnet. I recommend changing this func to this:

func removeNodesWithSubnetName(nodes []*v1.Node, subnetName string) []*v1.Node.

This should have its own unit test (TestFilterOutNodesFromN...)

Parse the subnet URL outside this func.

// Filter out any node that is not from the default network. This is required for multi-subnet feature.
// This should not change behavior for nodes that are in the default network.
// This can't be done earlier when listing node since the code is shared between internal and external LBs.
nodes = filterOutNodesFromNonDefaultNetworks(nodes, g.SubnetworkURL())
Copy link
Member

Choose a reason for hiding this comment

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

We need to handle SubnetworkURL parse failure, even if we think it's rare.

subnetLabel, ok := node.Labels[labelGKESubnetworkName]

if !ok && node.Spec.PodCIDR == "" {
continue
Copy link
Member

Choose a reason for hiding this comment

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

This actually deserves a comment as why this is skipped when PodCIDR == ""

if !ok && node.Spec.PodCIDR == "" {
continue
}
if ok && subnetLabel != "" && subnetLabel != subnetNameFromURL(defaultSubnetURL) {
Copy link
Member

Choose a reason for hiding this comment

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

Why would subnetNameFromURL == "" ever?

@bowei
Copy link
Member

bowei commented Jun 4, 2024

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 4, 2024
@bowei
Copy link
Member

bowei commented Jun 4, 2024

/triage-accepted

@@ -50,6 +50,8 @@ const (
maxInstancesPerInstanceGroup = 1000
// maxL4ILBPorts is the maximum number of ports that can be specified in an L4 ILB Forwarding Rule. Beyond this, "AllPorts" field should be used.
maxL4ILBPorts = 5
// labelGKESubnetworkName is the key of the label that contains the subnet name the node is connected to.
labelGKESubnetworkName = "cloud.google.com/gke-np-subnet"
Copy link
Member

Choose a reason for hiding this comment

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

Is it too late to remove the abbreviation here?

gke-np-subnet => gke-node-pool-subnet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants