Skip to content

Commit

Permalink
Add L7XLBRegionalEnabled to translator and service port
Browse files Browse the repository at this point in the history
Should be no-op
  • Loading branch information
panslava committed Oct 26, 2023
1 parent 6bf54a1 commit 9b27d22
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 23 deletions.
3 changes: 2 additions & 1 deletion pkg/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ func NewControllerContext(
context.PodInformer,
context.EndpointSliceInformer,
context.KubeClient,
flags.F.EnableTransparentHealthChecks,
context,
flags.F.EnableTransparentHealthChecks,
context.EnableIngressRegionalExternal,
)
context.InstancePool = instancegroups.NewManager(&instancegroups.ManagerConfig{
Cloud: context.Cloud,
Expand Down
31 changes: 20 additions & 11 deletions pkg/controller/translator/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ const (

// getServicePortParams allows for passing parameters to getServicePort()
type getServicePortParams struct {
isL7ILB bool
isL7ILB bool
isL7XLBRegional bool
}

// NewTranslator returns a new Translator.
Expand All @@ -67,8 +68,10 @@ func NewTranslator(serviceInformer cache.SharedIndexInformer,
podInformer cache.SharedIndexInformer,
endpointSliceInformer cache.SharedIndexInformer,
kubeClient kubernetes.Interface,
enableTHC bool,
recorderGetter healthchecks.RecorderGetter) *Translator {
recorderGetter healthchecks.RecorderGetter,
enableTHC,
enableL7XLBRegional bool,
) *Translator {
return &Translator{
ServiceInformer: serviceInformer,
BackendConfigInformer: backendConfigInformer,
Expand All @@ -78,6 +81,7 @@ func NewTranslator(serviceInformer cache.SharedIndexInformer,
KubeClient: kubeClient,
enableTHC: enableTHC,
recorderGetter: recorderGetter,
enableL7XLBRegional: enableL7XLBRegional,
}
}

Expand All @@ -89,8 +93,9 @@ type Translator struct {
PodInformer cache.SharedIndexInformer
EndpointSliceInformer cache.SharedIndexInformer
KubeClient kubernetes.Interface
enableTHC bool
recorderGetter healthchecks.RecorderGetter
enableTHC bool
enableL7XLBRegional bool
}

func (t *Translator) getCachedService(id utils.ServicePortID) (*api_v1.Service, error) {
Expand Down Expand Up @@ -272,13 +277,14 @@ func (t *Translator) getServicePort(id utils.ServicePortID, params *getServicePo
// We periodically add information to the ServicePort to ensure that we
// always return as much as possible, rather than nil, if there was a non-fatal error.
svcPort := &utils.ServicePort{
ID: id,
NodePort: int64(port.NodePort),
Port: port.Port,
PortName: port.Name,
TargetPort: port.TargetPort,
L7ILBEnabled: params.isL7ILB,
BackendNamer: namer,
ID: id,
NodePort: int64(port.NodePort),
Port: port.Port,
PortName: port.Name,
TargetPort: port.TargetPort,
L7ILBEnabled: params.isL7ILB,
L7XLBRegionalEnabled: params.isL7XLBRegional,
BackendNamer: namer,
}

if err := maybeEnableNEG(svcPort, svc); err != nil {
Expand Down Expand Up @@ -313,6 +319,9 @@ func (t *Translator) TranslateIngress(ing *v1.Ingress, systemDefaultBackend util

params := &getServicePortParams{}
params.isL7ILB = utils.IsGCEL7ILBIngress(ing)
if t.enableL7XLBRegional {
params.isL7XLBRegional = utils.IsGCEL7XLBRegionalIngress(ing)
}

for _, rule := range ing.Spec.Rules {
if rule.HTTP == nil {
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ func configuredFakeTranslator() *Translator {
PodInformer,
EndpointSliceInformer,
client,
false,
healthchecks.NewFakeRecorderGetter(0),
false,
false,
)
}

Expand Down
21 changes: 11 additions & 10 deletions pkg/utils/serviceport.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,17 @@ type ServicePort struct {
// Numerical port of the Service, retrieved from the Service
Port int32
// Name of the port of the Service, retrieved from the Service
PortName string
Protocol annotations.AppProtocol
TargetPort intstr.IntOrString
NEGEnabled bool
VMIPNEGEnabled bool
L4RBSEnabled bool
L7ILBEnabled bool
THCConfiguration THCConfiguration
BackendConfig *backendconfigv1.BackendConfig
BackendNamer namer.BackendNamer
PortName string
Protocol annotations.AppProtocol
TargetPort intstr.IntOrString
NEGEnabled bool
VMIPNEGEnabled bool
L4RBSEnabled bool
L7ILBEnabled bool
L7XLBRegionalEnabled bool
THCConfiguration THCConfiguration
BackendConfig *backendconfigv1.BackendConfig
BackendNamer namer.BackendNamer
// Traffic policy fields that apply if non-nil.
MaxRatePerEndpoint *float64
CapacityScaler *float64
Expand Down

0 comments on commit 9b27d22

Please sign in to comment.