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

NEG controller part - L4 RBS External LB NEG support #2566

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mmamczur
Copy link
Contributor

@mmamczur mmamczur commented May 23, 2024

This PR contains changes for the NEG controller to support L4 NetLB services.
The NEG controller will be triggered for NetLBs with the presence of the new netlb V3 finalizer

Also the PortInfo had to be extended to contain the type of L4 LB since the calculators need this info in order to pick the right subset sizes. NetLBs will use larger subsets than ILB. Also this allows to differentiate a NEG syncer for ILB vs one for NetLB, when the service moves between ILB and NetLB the syncer for the old service spec will be stopped and a new one created for the changed service.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 23, 2024
@mmamczur mmamczur force-pushed the ext_l4_lb_negs_neg_controller branch 2 times, most recently from 3633223 to d167e04 Compare May 24, 2024 11:00
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 24, 2024
@mmamczur mmamczur force-pushed the ext_l4_lb_negs_neg_controller branch from d167e04 to 8c10715 Compare May 29, 2024 07:36
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 29, 2024
@mmamczur
Copy link
Contributor Author

/assign @swetharepakula
/assign @sawsa307

@mmamczur
Copy link
Contributor Author

/hold

let's not merge this before the next code freeze ends

@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 May 29, 2024
Copy link
Member

@swetharepakula swetharepakula left a comment

Choose a reason for hiding this comment

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

Though the core logic of selecting endpoints has not changed, I think we need more tests to cover this new knob.

pkg/neg/controller.go Outdated Show resolved Hide resolved
@@ -37,7 +37,7 @@ import (
"k8s.io/klog/v2"
)

// TestLocalGetEndpointSet verifies the GetEndpointSet method implemented by the LocalL4ILBEndpointsCalculator.
// TestLocalGetEndpointSet verifies the GetEndpointSet method implemented by the LocalL4EndpointsCalculator.
Copy link
Member

Choose a reason for hiding this comment

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

Can you add tests to cover the logic of switching between netlb and ilb?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is a good point, adding a test here won't help much. To sum up
The NetLB and ILB will use the same syncing logic but with different subset sizes.
The endpoint calculators are created together with the syncer and keep 'living' in the controller.
There is no mechanism to update the running syncers. What we can do here is to treat these syncers as different. When the service is moved ILB <-> NetLB just stop the old syncer and create a new one. I added the LB type to the syncer key, this will achieve just that.
I intended to add a test for this in the controller_test, it would work but there is a problem with the fake SvcNEG indexer and client. When a SvcNEG is created the indexer doesn't know. There is code that checks if an object extsts using the indexer and then uses the client to delete

obj, exists, err := manager.svcNegLister.GetByKey(fmt.Sprintf("%s/%s", namespace, negName))
if err != nil {
return fmt.Errorf("failed retrieving neg %s/%s to delete: %w", namespace, negName, err)
}
if !exists {
return nil
}
neg := obj.(*negv1beta1.ServiceNetworkEndpointGroup)
if neg.GetDeletionTimestamp().IsZero() {
start := time.Now()
err = manager.svcNegClient.NetworkingV1beta1().ServiceNetworkEndpointGroups(namespace).Delete(context.Background(), negName, metav1.DeleteOptions{})
metrics.PublishK8sRequestCountMetrics(start, metrics.DeleteRequest, err)
if err != nil {
return fmt.Errorf("errored while deleting neg cr %s/%s: %w", negName, namespace, err)
}
manager.logger.V(2).Info("Deleted neg cr", "svcneg", klog.KRef(namespace, negName))
}
return nil
. Of course in this case it does not delete since it thinks the object does not exist.
Not sure how to resolve it. Maybe just e2e test that handles that case?

@@ -158,6 +158,7 @@ func newTestControllerWithParamsAndContext(kubeClient kubernetes.Interface, test
labels.PodLabelPropagationConfig{},
true,
false,
false,
Copy link
Member

Choose a reason for hiding this comment

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

can you add tests where this is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added a test case to verify combinations of this being turned off etc

@mmamczur mmamczur force-pushed the ext_l4_lb_negs_neg_controller branch from 8c10715 to c6b0781 Compare June 10, 2024 10:34
@mmamczur mmamczur force-pushed the ext_l4_lb_negs_neg_controller branch from c6b0781 to 59cfac4 Compare July 17, 2024 08:28
@mmamczur mmamczur force-pushed the ext_l4_lb_negs_neg_controller branch 2 times, most recently from 7acfed4 to 8645452 Compare August 13, 2024 13:55
@mmamczur mmamczur force-pushed the ext_l4_lb_negs_neg_controller branch 2 times, most recently from 2f44c5c to 7a219f0 Compare September 11, 2024 14:53
@cezarygerard
Copy link
Contributor

I have reviewed this changes in #2565

it looks good to me

please merge these as soon as we have LGMT from Swetha and Gaurav

Adds 2 new flags related to NetLB RBS NEG support.
`--enable-l4-netlb-neg` that will allow to create NEGs for L4 NetLBs.
`--enable-l4-netlb-neg-default` which will make all new RBS services use NEG backends.
NetLBFinalizerV3 will be added to the L4 RBS NetLBs that opt-in for NEG support.
When enabled, the NEG controller will create NEGs for L4 RBS NetLBs that are marked by the L4 NetLB controller to be NEG based.
@sawsa307
Copy link
Contributor

Looks good to me, will leave the final approval to @swetharepakula

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mmamczur, sawsa307

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

The pull request process is described 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. 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. 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.

5 participants