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

Add backend_type label to l4_netlbs_count and the L4_netlb latency metrics #2691

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

mmamczur
Copy link
Contributor

This extends the L4 NetLB metrics with backend_type field that will allow tracking the adoption and performance of NEG backed LBs vs IG ones.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 30, 2024
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 30, 2024
@mmamczur
Copy link
Contributor Author

mmamczur commented Oct 1, 2024

/assign @swetharepakula

if err := common.EnsureServiceFinalizer(service, common.NetLBFinalizerV2, lc.ctx.KubeClient, svcLogger); err != nil {
finalizer := common.NetLBFinalizerV2
if usesNegBackends {
finalizer = common.NetLBFinalizerV3
Copy link
Contributor

Choose a reason for hiding this comment

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

This change would require us to update the old controller to verify that it detects it's an RBS if it has V3 finalizer:
https://github.com/kubernetes/cloud-provider-gcp/blob/master/providers/gce/gce_util.go#L409

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you are right, we should add it. IT shouldn't be a problem unless someone removes the rbs annotation so we should update CCM anyway

pkg/l4lb/l4netlbcontroller.go Outdated Show resolved Hide resolved
@@ -94,7 +94,7 @@ func NewL4ILBSyncResult(syncType string, startTime time.Time, svc *corev1.Servic
StartTime: startTime,
SyncType: syncType,
// Internal Load Balancer doesn't support strong session affinity (passing `false` all along)
MetricsState: metrics.InitServiceMetricsState(svc, &startTime, isMultinetService, enabledStrongSessionAffinity, isWeightedLBPodsPerNode),
MetricsState: metrics.InitServiceMetricsState(svc, &startTime, isMultinetService, enabledStrongSessionAffinity, isWeightedLBPodsPerNode, metrics.L4BackendTypeNEG),
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider creating a variable for metrics.L4BackendTypeNEG

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 a constant, I'd say we don't need a variable to hold it

pkg/metrics/l4_metrics.go Outdated Show resolved Hide resolved
updatedObjectMeta.Finalizers = slice.RemoveString(updatedObjectMeta.Finalizers, key, nil)
}

svcLogger.V(2).Info("Removing finalizers from service", "finalizerKeys", ensureRemoveKeys)
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace ensureRemoveKeys with needToRemove

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of having 2 for loops you can combine both in one:

Suggested change
svcLogger.V(2).Info("Removing finalizers from service", "finalizerKeys", ensureRemoveKeys)
updatedObjectMeta := service.ObjectMeta.DeepCopy()
modified := false
for _, key := range ensureRemoveKeys {
if HasGivenFinalizer(service.ObjectMeta, key) {
updatedObjectMeta.Finalizers = slice.RemoveString(updatedObjectMeta.Finalizers, key, nil)
svcLogger.V(2).Info("Removing finalizer from service", "finalizerKey", key)
modified = true
}
}
if !modified {
return nil
}
return patch.PatchServiceObjectMetadata(kubeClient.CoreV1(), service, *updatedObjectMeta)

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 was actually part of the parent commit that was merged yesterday

…trics.

This will be used to track number of LBs with NEG backends vs ones with IG backends.
@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 Oct 2, 2024
@mmamczur
Copy link
Contributor Author

mmamczur commented Oct 2, 2024

/hold
need to make sure to update monarch schema with the new field before merging

@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 Oct 2, 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.

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [mmamczur,swetharepakula]

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

@mmamczur
Copy link
Contributor Author

mmamczur commented Oct 4, 2024

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 4, 2024
@k8s-ci-robot k8s-ci-robot merged commit 00f535d into kubernetes:master Oct 4, 2024
5 checks passed
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants