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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/l4lb/l4netlbcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,8 @@ func (lc *L4NetLBController) syncInternal(service *v1.Service, svcLogger klog.Lo
svcLogger.Info("Finished syncing L4 NetLB RBS service", "timeTaken", time.Since(startTime))
}()

usesNegBackends := lc.shouldUseNEGBackends(service)

l4NetLBParams := &loadbalancers.L4NetLBParams{
Service: service,
Cloud: lc.ctx.Cloud,
Expand All @@ -543,10 +545,10 @@ func (lc *L4NetLBController) syncInternal(service *v1.Service, svcLogger klog.Lo
NetworkResolver: lc.networkResolver,
EnableWeightedLB: lc.ctx.EnableWeightedL4NetLB,
DisableNodesFirewallProvisioning: lc.ctx.DisableL4LBFirewall,
UseNEGs: usesNegBackends,
}
l4netlb := loadbalancers.NewL4NetLB(l4NetLBParams, svcLogger)

usesNegBackends := lc.shouldUseNEGBackends(service)
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

Expand Down Expand Up @@ -819,5 +821,7 @@ func (lc *L4NetLBController) publishSyncMetrics(result *loadbalancers.L4NetLBSyn
l4metrics.PublishL4SyncDetails(l4NetLBControllerName, result.Error == nil, isResync, result.GCEResourceUpdate.WereAnyResourcesModified())

isWeightedLB := result.MetricsState.WeightedLBPodsPerNode
l4metrics.PublishNetLBSyncMetrics(result.Error == nil, result.SyncType, result.GCEResourceInError, utils.GetErrorType(result.Error), result.StartTime, isResync, isWeightedLB)
backendType := result.MetricsState.BackendType

l4metrics.PublishNetLBSyncMetrics(result.Error == nil, result.SyncType, result.GCEResourceInError, utils.GetErrorType(result.Error), result.StartTime, isResync, isWeightedLB, backendType)
}
16 changes: 11 additions & 5 deletions pkg/l4lb/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"k8s.io/ingress-gce/pkg/metrics"
"k8s.io/klog/v2"
)

Expand Down Expand Up @@ -51,6 +52,11 @@ var (
"sync_type", // whether this is a new service, update or delete
"periodic_resync", // whether the sync was periodic resync or a update caused by a resource change
}

l4SyncLatencyNetLBSpecificMetricLabels = []string{
"backend_type", // type of the backends of the LB (IG or NEG)
}

l4LBSyncLatencyMetricsLabels = append(l4LBSyncLatencyCommonMetricLabels, l4WeightedLBPodsPerNodeMetricName)
l4LBDualStackSyncLatencyMetricsLabels = append(l4LBSyncLatencyCommonMetricLabels, "ip_families")
l4LBSyncErrorMetricLabels = []string{
Expand Down Expand Up @@ -113,7 +119,7 @@ var (
// using funny starter bucket, 0.9375s will only add buckets to existing metric, this is a safe operation in most time series db
Buckets: prometheus.ExponentialBuckets(0.9375, 2, 15),
},
l4LBSyncLatencyMetricsLabels,
append(l4LBSyncLatencyMetricsLabels, l4SyncLatencyNetLBSpecificMetricLabels...),
)
l4NetLBDualStackSyncLatency = prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Expand Down Expand Up @@ -248,8 +254,8 @@ func PublishL4ILBMultiNetSyncLatency(success bool, syncType string, startTime ti
}

// PublishNetLBSyncMetrics exports metrics related to the L4 NetLB sync.
func PublishNetLBSyncMetrics(success bool, syncType, gceResource, errType string, startTime time.Time, isResync bool, isWeightedLB bool) {
publishL4NetLBSync(success, syncType, startTime, isResync, isWeightedLB)
func PublishNetLBSyncMetrics(success bool, syncType, gceResource, errType string, startTime time.Time, isResync bool, isWeightedLB bool, l4BackendType metrics.L4BackendType) {
publishL4NetLBSync(success, syncType, startTime, isResync, isWeightedLB, l4BackendType)
if !success {
publishL4NetLBSyncErrorCount(syncType, gceResource, errType, isWeightedLB)
}
Expand All @@ -270,12 +276,12 @@ func publishL4ILBSyncErrorCount(syncType, gceResource, errorType string, isWeigh
}

// publishL4NetLBSync exports latency metrics for L4 NetLB service after sync.
func publishL4NetLBSync(success bool, syncType string, startTime time.Time, isResync bool, isWeightedLB bool) {
func publishL4NetLBSync(success bool, syncType string, startTime time.Time, isResync bool, isWeightedLB bool, backendType metrics.L4BackendType) {
status := statusSuccess
if !success {
status = statusError
}
l4NetLBSyncLatency.WithLabelValues(status, syncType, strconv.FormatBool(isResync), strconv.FormatBool(isWeightedLB)).Observe(time.Since(startTime).Seconds())
l4NetLBSyncLatency.WithLabelValues(status, syncType, strconv.FormatBool(isResync), strconv.FormatBool(isWeightedLB), string(backendType)).Observe(time.Since(startTime).Seconds())
}

// PublishL4NetLBDualStackSyncLatency exports the given sync latency datapoint.
Expand Down
2 changes: 1 addition & 1 deletion pkg/loadbalancers/l4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
return result
}
Expand Down
16 changes: 12 additions & 4 deletions pkg/loadbalancers/l4netlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type L4NetLB struct {
enableWeightedLB bool
disableNodesFirewallProvisioning bool
svcLogger klog.Logger
useNEGs bool
}

// L4NetLBSyncResult contains information about the outcome of an L4 NetLB sync. It stores the list of resource name annotations,
Expand Down Expand Up @@ -129,14 +130,19 @@ func (ru *ResourceUpdates) String() string {
return "-"
}

func NewL4SyncResult(syncType string, svc *corev1.Service, isMultinet bool, enabledStrongSessionAffinity bool, isWeightedLBPodsPerNode bool) *L4NetLBSyncResult {
func NewL4SyncResult(syncType string, svc *corev1.Service, isMultinet bool, enabledStrongSessionAffinity bool, isWeightedLBPodsPerNode bool, useNEGs bool) *L4NetLBSyncResult {
startTime := time.Now()
backendType := metrics.L4BackendTypeInstanceGroup
if useNEGs || isMultinet {
backendType = metrics.L4BackendTypeNEG
}

result := &L4NetLBSyncResult{
Annotations: make(map[string]string),
StartTime: startTime,
SyncType: syncType,
MetricsLegacyState: metrics.InitL4NetLBServiceLegacyState(&startTime),
MetricsState: metrics.InitServiceMetricsState(svc, &startTime, isMultinet, enabledStrongSessionAffinity, isWeightedLBPodsPerNode),
MetricsState: metrics.InitServiceMetricsState(svc, &startTime, isMultinet, enabledStrongSessionAffinity, isWeightedLBPodsPerNode, backendType),
}
return result
}
Expand All @@ -159,6 +165,7 @@ type L4NetLBParams struct {
NetworkResolver network.Resolver
EnableWeightedLB bool
DisableNodesFirewallProvisioning bool
UseNEGs bool
}

// NewL4NetLB creates a new Handler for the given L4NetLB service.
Expand All @@ -179,6 +186,7 @@ func NewL4NetLB(params *L4NetLBParams, logger klog.Logger) *L4NetLB {
networkResolver: params.NetworkResolver,
enableWeightedLB: params.EnableWeightedLB,
disableNodesFirewallProvisioning: params.DisableNodesFirewallProvisioning,
useNEGs: params.UseNEGs,
svcLogger: logger,
}
return l4netlb
Expand Down Expand Up @@ -237,7 +245,7 @@ func (l4netlb *L4NetLB) EnsureFrontend(nodeNames []string, svc *corev1.Service)
isMultinetService := l4netlb.networkResolver.IsMultinetService(svc)
serviceUsesSSA := l4netlb.enableStrongSessionAffinity && annotations.HasStrongSessionAffinityAnnotation(l4netlb.Service)
isWeightedLBPodsPerNode := l4netlb.isWeightedLBPodsPerNode()
result := NewL4SyncResult(SyncTypeCreate, svc, isMultinetService, serviceUsesSSA, isWeightedLBPodsPerNode)
result := NewL4SyncResult(SyncTypeCreate, svc, isMultinetService, serviceUsesSSA, isWeightedLBPodsPerNode, l4netlb.useNEGs)
// If service already has an IP assigned, treat it as an update instead of a new Loadbalancer.
if len(svc.Status.LoadBalancer.Ingress) > 0 {
result.SyncType = SyncTypeUpdate
Expand Down Expand Up @@ -490,7 +498,7 @@ func (l4netlb *L4NetLB) EnsureLoadBalancerDeleted(svc *corev1.Service) *L4NetLBS
isMultinetService := l4netlb.networkResolver.IsMultinetService(svc)
useSSA := l4netlb.enableStrongSessionAffinity && annotations.HasStrongSessionAffinityAnnotation(l4netlb.Service)
isWeightedLBPodsPerNode := l4netlb.isWeightedLBPodsPerNode()
result := NewL4SyncResult(SyncTypeDelete, svc, isMultinetService, useSSA, isWeightedLBPodsPerNode)
result := NewL4SyncResult(SyncTypeDelete, svc, isMultinetService, useSSA, isWeightedLBPodsPerNode, l4netlb.useNEGs)

l4netlb.Service = svc

Expand Down
7 changes: 5 additions & 2 deletions pkg/metrics/l4_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const (
l4LabelMultinet = "multinet"
l4LabelStrongSessionAffinity = "strong_session_affinity"
l4LabelWeightedLBPodsPerNode = "weighted_lb_pods_per_node"
l4LabelBackendType = "backend_type"
)

var (
Expand All @@ -47,7 +48,7 @@ var (
Name: "l4_netlbs_count",
Help: "Metric containing the number of NetLBs that can be filtered by feature labels and status",
},
[]string{l4LabelStatus, l4LabelMultinet, l4LabelStrongSessionAffinity, l4LabelWeightedLBPodsPerNode},
[]string{l4LabelStatus, l4LabelMultinet, l4LabelStrongSessionAffinity, l4LabelWeightedLBPodsPerNode, l4LabelBackendType},
)
)

Expand All @@ -56,7 +57,7 @@ func (im *ControllerMetrics) exportL4Metrics() {
im.exportL4NetLBsMetrics()
}

func InitServiceMetricsState(svc *corev1.Service, startTime *time.Time, isMultinetwork bool, enabledStrongSessionAffinity bool, isWeightedLBPodsPerNode bool) L4ServiceState {
func InitServiceMetricsState(svc *corev1.Service, startTime *time.Time, isMultinetwork bool, enabledStrongSessionAffinity bool, isWeightedLBPodsPerNode bool, backendType L4BackendType) L4ServiceState {
state := L4ServiceState{
L4DualStackServiceLabels: L4DualStackServiceLabels{
IPFamilies: ipFamiliesToString(svc.Spec.IPFamilies),
Expand All @@ -65,6 +66,7 @@ func InitServiceMetricsState(svc *corev1.Service, startTime *time.Time, isMultin
Multinetwork: isMultinetwork,
StrongSessionAffinity: enabledStrongSessionAffinity,
WeightedLBPodsPerNode: isWeightedLBPodsPerNode,
BackendType: backendType,
},
// Always init status with error, and update with Success when service was provisioned
Status: StatusError,
Expand Down Expand Up @@ -162,6 +164,7 @@ func (im *ControllerMetrics) exportL4NetLBsMetrics() {
l4LabelMultinet: strconv.FormatBool(svcState.Multinetwork),
l4LabelStrongSessionAffinity: strconv.FormatBool(svcState.StrongSessionAffinity),
l4LabelWeightedLBPodsPerNode: strconv.FormatBool(svcState.WeightedLBPodsPerNode),
l4LabelBackendType: string(svcState.BackendType),
}).Inc()
}
im.logger.V(3).Info("L4 NetLB usage metrics exported")
Expand Down
42 changes: 21 additions & 21 deletions pkg/metrics/l4_metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,52 +109,52 @@ func TestExportNetLBMetric(t *testing.T) {
notExceedingPersistentErrorThresholdTime := time.Now().Add(-1*persistentErrorThresholdTime + 5*time.Minute)

newMetrics.SetL4NetLBService("svc-success-multinet-1", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: true, StrongSessionAffinity: false, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: true, StrongSessionAffinity: false, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeNEG},
Status: StatusSuccess,
})
newMetrics.SetL4NetLBService("svc-success-all-labels", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: true, StrongSessionAffinity: true, WeightedLBPodsPerNode: true},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: true, StrongSessionAffinity: true, WeightedLBPodsPerNode: true, BackendType: L4BackendTypeNEG},
Status: StatusSuccess,
})
newMetrics.SetL4NetLBService("svc-success-multinet-2", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: true, StrongSessionAffinity: false, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: true, StrongSessionAffinity: false, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeNEG},
Status: StatusSuccess,
})
newMetrics.SetL4NetLBService("svc-success-ssa", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: true, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: true, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeNEG},
Status: StatusSuccess,
})
newMetrics.SetL4NetLBService("svc-success-weightedlb", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: true},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: true, BackendType: L4BackendTypeInstanceGroup},
Status: StatusSuccess,
})
newMetrics.SetL4NetLBService("svc-user-error-ssa", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: true, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: true, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeInstanceGroup},
Status: StatusUserError,
})
newMetrics.SetL4NetLBService("svc-error", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeInstanceGroup},
Status: StatusError,
FirstSyncErrorTime: &notExceedingPersistentErrorThresholdTime,
})
newMetrics.SetL4NetLBService("svc-error", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeInstanceGroup},
Status: StatusError,
FirstSyncErrorTime: &notExceedingPersistentErrorThresholdTime,
})
newMetrics.SetL4NetLBService("svc-threshold-check", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeInstanceGroup},
Status: StatusError,
FirstSyncErrorTime: &pastPersistentErrorThresholdTime,
})
// check that updating later does not move FirstSyncErrorTime
newMetrics.SetL4NetLBService("svc-threshold-check", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeInstanceGroup},
Status: StatusError,
FirstSyncErrorTime: &notExceedingPersistentErrorThresholdTime,
})
newMetrics.SetL4NetLBService("svc-single-stack", L4ServiceState{
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false},
L4FeaturesServiceLabels: L4FeaturesServiceLabels{Multinetwork: false, StrongSessionAffinity: false, WeightedLBPodsPerNode: false, BackendType: L4BackendTypeInstanceGroup},
L4DualStackServiceLabels: L4DualStackServiceLabels{
IPFamilies: "IPv4",
IPFamilyPolicy: "SingleStack",
Expand All @@ -165,19 +165,19 @@ func TestExportNetLBMetric(t *testing.T) {

newMetrics.exportL4NetLBsMetrics()

verifyL4NetLBMetric(t, 2, StatusSuccess, isMultinetwork, disabledStrongSessionAffinity, notWeightedLBPodsPerNode)
verifyL4NetLBMetric(t, 1, StatusSuccess, isMultinetwork, enabledStrongSessionAffinity, isWeightedLBPodsPerNode)
verifyL4NetLBMetric(t, 1, StatusSuccess, notMultinetwork, enabledStrongSessionAffinity, notWeightedLBPodsPerNode)
verifyL4NetLBMetric(t, 1, StatusSuccess, notMultinetwork, disabledStrongSessionAffinity, isWeightedLBPodsPerNode)
verifyL4NetLBMetric(t, 1, StatusUserError, notMultinetwork, enabledStrongSessionAffinity, notWeightedLBPodsPerNode)
verifyL4NetLBMetric(t, 2, StatusError, notMultinetwork, disabledStrongSessionAffinity, notWeightedLBPodsPerNode)
verifyL4NetLBMetric(t, 1, StatusPersistentError, notMultinetwork, disabledStrongSessionAffinity, notWeightedLBPodsPerNode)
verifyL4NetLBMetric(t, 2, StatusSuccess, isMultinetwork, disabledStrongSessionAffinity, notWeightedLBPodsPerNode, L4BackendTypeNEG)
verifyL4NetLBMetric(t, 1, StatusSuccess, isMultinetwork, enabledStrongSessionAffinity, isWeightedLBPodsPerNode, L4BackendTypeNEG)
verifyL4NetLBMetric(t, 1, StatusSuccess, notMultinetwork, enabledStrongSessionAffinity, notWeightedLBPodsPerNode, L4BackendTypeNEG)
verifyL4NetLBMetric(t, 1, StatusSuccess, notMultinetwork, disabledStrongSessionAffinity, isWeightedLBPodsPerNode, L4BackendTypeInstanceGroup)
verifyL4NetLBMetric(t, 1, StatusUserError, notMultinetwork, enabledStrongSessionAffinity, notWeightedLBPodsPerNode, L4BackendTypeInstanceGroup)
verifyL4NetLBMetric(t, 2, StatusError, notMultinetwork, disabledStrongSessionAffinity, notWeightedLBPodsPerNode, L4BackendTypeInstanceGroup)
verifyL4NetLBMetric(t, 1, StatusPersistentError, notMultinetwork, disabledStrongSessionAffinity, notWeightedLBPodsPerNode, L4BackendTypeInstanceGroup)
}

func verifyL4NetLBMetric(t *testing.T, expectedCount int, status L4ServiceStatus, multinet string, strongSessionAffinity string, weightedLBPodsPerNode string) {
countFloat := testutil.ToFloat64(l4NetLBCount.With(prometheus.Labels{l4LabelStatus: string(status), l4LabelMultinet: multinet, l4LabelStrongSessionAffinity: strongSessionAffinity, l4LabelWeightedLBPodsPerNode: weightedLBPodsPerNode}))
func verifyL4NetLBMetric(t *testing.T, expectedCount int, status L4ServiceStatus, multinet string, strongSessionAffinity string, weightedLBPodsPerNode string, backendType L4BackendType) {
countFloat := testutil.ToFloat64(l4NetLBCount.With(prometheus.Labels{l4LabelStatus: string(status), l4LabelMultinet: multinet, l4LabelStrongSessionAffinity: strongSessionAffinity, l4LabelWeightedLBPodsPerNode: weightedLBPodsPerNode, l4LabelBackendType: string(backendType)}))
actualCount := int(math.Round(countFloat))
if expectedCount != actualCount {
t.Errorf("expected value %d but got %d", expectedCount, actualCount)
t.Errorf("expected value %d but got %d for status: %q, multinet: %q, ssa: %q, backendType: %q", expectedCount, actualCount, status, multinet, strongSessionAffinity, backendType)
}
}
7 changes: 7 additions & 0 deletions pkg/metrics/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const StatusUserError = L4ServiceStatus("UserError")
const StatusError = L4ServiceStatus("Error")
const StatusPersistentError = L4ServiceStatus("PersistentError")

type L4BackendType string

const L4BackendTypeInstanceGroup = L4BackendType("IG")
const L4BackendTypeNEG = L4BackendType("NEG")

// L4DualStackServiceLabels defines ipFamilies, ipFamilyPolicy
// of L4 DualStack service
type L4DualStackServiceLabels struct {
Expand All @@ -68,6 +73,8 @@ type L4FeaturesServiceLabels struct {
StrongSessionAffinity bool
// WeightedLBPodsPerNode is true if weighted load balancing is enabled by pods per node
WeightedLBPodsPerNode bool
// BackendType is the type of the backend the LB uses (IGs or NEGs).
BackendType L4BackendType
}

// L4ServiceState tracks the state of an L4 service. It includes data needed to fill various L4 metrics plus the status of the service.
Expand Down