From 8e35c9f92639e12159eda9f2ee36cbd79bc53c3c Mon Sep 17 00:00:00 2001 From: "Lawrence G." Date: Mon, 13 Jan 2025 16:29:50 -0600 Subject: [PATCH] cleanup and reorg (#10434) --- projects/gateway2/controller/start.go | 3 +- .../extensions2/plugins/kubernetes/k8s.go | 8 ++- .../routepolicy/route_policy_plugin.go | 13 ++-- projects/gateway2/krtcollections/policy.go | 62 +++++++++++++------ projects/gateway2/krtcollections/setup.go | 45 ++++++++------ projects/gateway2/proxy_syncer/cla.go | 5 +- projects/gateway2/proxy_syncer/perclient.go | 10 ++- .../gateway2/proxy_syncer/proxy_syncer.go | 25 +++++++- projects/gateway2/query/httproute.go | 17 +++-- projects/gateway2/query/query.go | 17 +---- projects/gateway2/setup/ggv2setup.go | 14 ++--- .../translator/irtranslator/upstream.go | 6 +- .../listener/gateway_listener_translator.go | 2 - projects/gateway2/translator/translator.go | 2 +- 14 files changed, 137 insertions(+), 92 deletions(-) diff --git a/projects/gateway2/controller/start.go b/projects/gateway2/controller/start.go index 54627afdcc1..e888e04ffb0 100644 --- a/projects/gateway2/controller/start.go +++ b/projects/gateway2/controller/start.go @@ -160,12 +160,13 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil cfg.SetupOpts.Cache, ) proxySyncer.Init(ctx, isOurGw, cfg.KrtOptions) + if err := mgr.Add(proxySyncer); err != nil { setupLog.Error(err, "unable to add proxySyncer runnable") return nil, err } - setupLog.Info("starting controller builder", "GatewayClasses", sets.List(gwClasses)) + setupLog.Info("starting controller builder", "GatewayClasses", sets.List(gwClasses)) return &ControllerBuilder{ proxySyncer: proxySyncer, cfg: cfg, diff --git a/projects/gateway2/extensions2/plugins/kubernetes/k8s.go b/projects/gateway2/extensions2/plugins/kubernetes/k8s.go index dfeba3b2ce7..681944c4235 100644 --- a/projects/gateway2/extensions2/plugins/kubernetes/k8s.go +++ b/projects/gateway2/extensions2/plugins/kubernetes/k8s.go @@ -29,10 +29,14 @@ func NewPlugin(ctx context.Context, commoncol *common.CommonCollections) extensi return NewPluginFromCollections(ctx, commoncol.KrtOpts, commoncol.Settings, commoncol.Pods, services, endpointSlices) } -func NewPluginFromCollections(ctx context.Context, krtOpts krtutil.KrtOptions, +func NewPluginFromCollections( + ctx context.Context, + krtOpts krtutil.KrtOptions, settings krt.Singleton[glookubev1.Settings], pods krt.Collection[krtcollections.LocalityPod], - services krt.Collection[*corev1.Service], endpointSlices krt.Collection[*discoveryv1.EndpointSlice]) extensionsplug.Plugin { + services krt.Collection[*corev1.Service], + endpointSlices krt.Collection[*discoveryv1.EndpointSlice], +) extensionsplug.Plugin { gk := schema.GroupKind{ Group: corev1.GroupName, Kind: "Service", diff --git a/projects/gateway2/extensions2/plugins/routepolicy/route_policy_plugin.go b/projects/gateway2/extensions2/plugins/routepolicy/route_policy_plugin.go index 67bc3748bc1..043dea274a6 100644 --- a/projects/gateway2/extensions2/plugins/routepolicy/route_policy_plugin.go +++ b/projects/gateway2/extensions2/plugins/routepolicy/route_policy_plugin.go @@ -40,7 +40,6 @@ type routeOptsPluginGwPass struct { } func NewPlugin(ctx context.Context, commoncol *common.CommonCollections) extensionplug.Plugin { - col := krtutil.SetupCollectionDynamic[v1alpha1.RoutePolicy]( ctx, commoncol.Client, @@ -48,17 +47,17 @@ func NewPlugin(ctx context.Context, commoncol *common.CommonCollections) extensi commoncol.KrtOpts.ToOptions("RoutePolicy")..., ) gk := v1alpha1.RoutePolicyGVK.GroupKind() - policyCol := krt.NewCollection(col, func(krtctx krt.HandlerContext, i *v1alpha1.RoutePolicy) *ir.PolicyWrapper { + policyCol := krt.NewCollection(col, func(krtctx krt.HandlerContext, policyCR *v1alpha1.RoutePolicy) *ir.PolicyWrapper { var pol = &ir.PolicyWrapper{ ObjectSource: ir.ObjectSource{ Group: gk.Group, Kind: gk.Kind, - Namespace: i.Namespace, - Name: i.Name, + Namespace: policyCR.Namespace, + Name: policyCR.Name, }, - Policy: i, - PolicyIR: &routeOptsPlugin{ct: i.CreationTimestamp.Time, spec: i.Spec}, - TargetRefs: convert(i.Spec.TargetRef), + Policy: policyCR, + PolicyIR: &routeOptsPlugin{ct: policyCR.CreationTimestamp.Time, spec: policyCR.Spec}, + TargetRefs: convert(policyCR.Spec.TargetRef), } return pol }) diff --git a/projects/gateway2/krtcollections/policy.go b/projects/gateway2/krtcollections/policy.go index bb705e54cc8..c086cad102e 100644 --- a/projects/gateway2/krtcollections/policy.go +++ b/projects/gateway2/krtcollections/policy.go @@ -39,7 +39,11 @@ type UpstreamIndex struct { krtopts krtutil.KrtOptions } -func NewUpstreamIndex(krtopts krtutil.KrtOptions, backendRefExtension []extensionsplug.GetBackendForRefPlugin, policies *PolicyIndex) *UpstreamIndex { +func NewUpstreamIndex( + krtopts krtutil.KrtOptions, + backendRefExtension []extensionsplug.GetBackendForRefPlugin, + policies *PolicyIndex, +) *UpstreamIndex { return &UpstreamIndex{ policies: policies, availableUpstreams: map[schema.GroupKind]krt.Collection[ir.Upstream]{}, @@ -70,7 +74,8 @@ func (ui *UpstreamIndex) Upstreams() []krt.Collection[ir.Upstream] { func (ui *UpstreamIndex) AddUpstreams(gk schema.GroupKind, col krt.Collection[ir.Upstream]) { ucol := krt.NewCollection(col, func(kctx krt.HandlerContext, u ir.Upstream) *ir.Upstream { - u.AttachedPolicies = toAttachedPolicies(ui.policies.getTargetingPolicies(kctx, extensionsplug.UpstreamAttachmentPoint, u.ObjectSource, "")) + policies := ui.policies.getTargetingPolicies(kctx, extensionsplug.UpstreamAttachmentPoint, u.ObjectSource, "") + u.AttachedPolicies = toAttachedPolicies(policies) return &u }, ui.krtopts.ToOptions("")...) ui.availableUpstreams[gk] = ucol @@ -145,7 +150,12 @@ type GatewayIndex struct { Gateways krt.Collection[ir.Gateway] } -func NewGatewayIndex(krtopts krtutil.KrtOptions, isOurGw func(gw *gwv1.Gateway) bool, policies *PolicyIndex, gws krt.Collection[*gwv1.Gateway]) *GatewayIndex { +func NewGatewayIndex( + krtopts krtutil.KrtOptions, + isOurGw func(gw *gwv1.Gateway) bool, + policies *PolicyIndex, + gws krt.Collection[*gwv1.Gateway], +) *GatewayIndex { h := &GatewayIndex{policies: policies} h.Gateways = krt.NewCollection(gws, func(kctx krt.HandlerContext, i *gwv1.Gateway) *ir.Gateway { if !isOurGw(i) { @@ -200,6 +210,7 @@ type PolicyIndex struct { hasSyncedFuncs []func() bool } +type policyFetcherMap = map[schema.GroupKind]func(n string, ns string) ir.PolicyIR func (h *PolicyIndex) HasSynced() bool { for _, f := range h.hasSyncedFuncs { @@ -211,20 +222,23 @@ func (h *PolicyIndex) HasSynced() bool { } func NewPolicyIndex(krtopts krtutil.KrtOptions, contributesPolicies extensionsplug.ContributesPolicies) *PolicyIndex { - - h := &PolicyIndex{policiesFetch: map[schema.GroupKind]func(n string, ns string) ir.PolicyIR{}} + h := &PolicyIndex{policiesFetch: policyFetcherMap{}} var policycols []krt.Collection[ir.PolicyWrapper] - for gk, ext := range contributesPolicies { - if ext.Policies != nil { - policycols = append(policycols, ext.Policies) - h.hasSyncedFuncs = append(h.hasSyncedFuncs, ext.Policies.Synced().HasSynced) - } - if ext.PoliciesFetch != nil { - h.policiesFetch[gk] = ext.PoliciesFetch - } - if ext.GlobalPolicies != nil { - h.globalPolicies = append(h.globalPolicies, globalPolicy{GroupKind: gk, ir: ext.GlobalPolicies, points: ext.AttachmentPoints()}) + for gk, plugin := range contributesPolicies { + if plugin.Policies != nil { + policycols = append(policycols, plugin.Policies) + h.hasSyncedFuncs = append(h.hasSyncedFuncs, plugin.Policies.Synced().HasSynced) + } + if plugin.PoliciesFetch != nil { + h.policiesFetch[gk] = plugin.PoliciesFetch + } + if plugin.GlobalPolicies != nil { + h.globalPolicies = append(h.globalPolicies, globalPolicy{ + GroupKind: gk, + ir: plugin.GlobalPolicies, + points: plugin.AttachmentPoints(), + }) } } @@ -245,10 +259,13 @@ func NewPolicyIndex(krtopts krtutil.KrtOptions, contributesPolicies extensionspl // Attachment happens during collection creation (i.e. this file), and not translation. so these methods don't need to be public! // note: we may want to change that for global policies maybe. -func (p *PolicyIndex) getTargetingPolicies(kctx krt.HandlerContext, pnt extensionsplug.AttachmentPoints, targetRef ir.ObjectSource, sectionName string) []ir.PolicyAtt { - +func (p *PolicyIndex) getTargetingPolicies( + kctx krt.HandlerContext, + pnt extensionsplug.AttachmentPoints, + targetRef ir.ObjectSource, + sectionName string, +) []ir.PolicyAtt { var ret []ir.PolicyAtt - for _, gp := range p.globalPolicies { if gp.points.Has(pnt) { if p := gp.ir(kctx, pnt); p != nil { @@ -430,7 +447,14 @@ func (h *RoutesIndex) HasSynced() bool { return h.httpRoutes.Synced().HasSynced() && h.routes.Synced().HasSynced() && h.policies.HasSynced() && h.upstreams.HasSynced() && h.refgrants.HasSynced() } -func NewRoutesIndex(krtopts krtutil.KrtOptions, httproutes krt.Collection[*gwv1.HTTPRoute], tcproutes krt.Collection[*gwv1a2.TCPRoute], policies *PolicyIndex, upstreams *UpstreamIndex, refgrants *RefGrantIndex) *RoutesIndex { +func NewRoutesIndex( + krtopts krtutil.KrtOptions, + httproutes krt.Collection[*gwv1.HTTPRoute], + tcproutes krt.Collection[*gwv1a2.TCPRoute], + policies *PolicyIndex, + upstreams *UpstreamIndex, + refgrants *RefGrantIndex, +) *RoutesIndex { h := &RoutesIndex{policies: policies, refgrants: refgrants, upstreams: upstreams} h.hasSyncedFuncs = append(h.hasSyncedFuncs, httproutes.Synced().HasSynced, tcproutes.Synced().HasSynced) diff --git a/projects/gateway2/krtcollections/setup.go b/projects/gateway2/krtcollections/setup.go index 4cd3790b463..41c5243abb9 100644 --- a/projects/gateway2/krtcollections/setup.go +++ b/projects/gateway2/krtcollections/setup.go @@ -53,13 +53,32 @@ func registerTypes() { ) } -func initCollectionsWithGateways(ctx context.Context, +func InitCollections( + ctx context.Context, + extensions extensionsplug.Plugin, + istioClient kube.Client, + isOurGw func(gw *gwv1.Gateway) bool, + refgrants *RefGrantIndex, + krtopts krtutil.KrtOptions, +) (*GatewayIndex, *RoutesIndex, krt.Collection[ir.Upstream], krt.Collection[ir.EndpointsForUpstream]) { + registerTypes() + + httpRoutes := krt.WrapClient(kclient.New[*gwv1.HTTPRoute](istioClient), krtopts.ToOptions("HTTPRoute")...) + tcproutes := krt.WrapClient(kclient.New[*gwv1a2.TCPRoute](istioClient), krtopts.ToOptions("TCPRoute")...) + kubeRawGateways := krt.WrapClient(kclient.New[*gwv1.Gateway](istioClient), krtopts.ToOptions("KubeGateways")...) + + return initCollectionsWithGateways(isOurGw, kubeRawGateways, httpRoutes, tcproutes, refgrants, extensions, krtopts) +} + +func initCollectionsWithGateways( isOurGw func(gw *gwv1.Gateway) bool, kubeRawGateways krt.Collection[*gwv1.Gateway], httpRoutes krt.Collection[*gwv1.HTTPRoute], tcproutes krt.Collection[*gwv1a2.TCPRoute], refgrants *RefGrantIndex, - extensions extensionsplug.Plugin, krtopts krtutil.KrtOptions) (*GatewayIndex, *RoutesIndex, krt.Collection[ir.Upstream], krt.Collection[ir.EndpointsForUpstream]) { + extensions extensionsplug.Plugin, + krtopts krtutil.KrtOptions, +) (*GatewayIndex, *RoutesIndex, krt.Collection[ir.Upstream], krt.Collection[ir.EndpointsForUpstream]) { policies := NewPolicyIndex(krtopts, extensions.ContributesPolicies) @@ -71,7 +90,7 @@ func initCollectionsWithGateways(ctx context.Context, } upstreamIndex := NewUpstreamIndex(krtopts, backendRefPlugins, policies) - finalUpstreams, endpointIRs := initUpstreams(ctx, extensions, upstreamIndex, krtopts) + finalUpstreams, endpointIRs := initUpstreams(extensions, upstreamIndex, krtopts) kubeGateways := NewGatewayIndex(krtopts, isOurGw, policies, kubeRawGateways) @@ -79,23 +98,11 @@ func initCollectionsWithGateways(ctx context.Context, return kubeGateways, routes, finalUpstreams, endpointIRs } -func InitCollections(ctx context.Context, +func initUpstreams( extensions extensionsplug.Plugin, - istioClient kube.Client, - isOurGw func(gw *gwv1.Gateway) bool, - refgrants *RefGrantIndex, - krtopts krtutil.KrtOptions) (*GatewayIndex, *RoutesIndex, krt.Collection[ir.Upstream], krt.Collection[ir.EndpointsForUpstream]) { - registerTypes() - - httpRoutes := krt.WrapClient(kclient.New[*gwv1.HTTPRoute](istioClient), krtopts.ToOptions("HTTPRoute")...) - tcproutes := krt.WrapClient(kclient.New[*gwv1a2.TCPRoute](istioClient), krtopts.ToOptions("TCPRoute")...) - kubeRawGateways := krt.WrapClient(kclient.New[*gwv1.Gateway](istioClient), krtopts.ToOptions("KubeGateways")...) - - return initCollectionsWithGateways(ctx, isOurGw, kubeRawGateways, httpRoutes, tcproutes, refgrants, extensions, krtopts) -} - -func initUpstreams(ctx context.Context, - extensions extensionsplug.Plugin, upstreamIndex *UpstreamIndex, krtopts krtutil.KrtOptions) (krt.Collection[ir.Upstream], krt.Collection[ir.EndpointsForUpstream]) { + upstreamIndex *UpstreamIndex, + krtopts krtutil.KrtOptions, +) (krt.Collection[ir.Upstream], krt.Collection[ir.EndpointsForUpstream]) { allEndpoints := []krt.Collection[ir.EndpointsForUpstream]{} for k, col := range extensions.ContributesUpstreams { diff --git a/projects/gateway2/proxy_syncer/cla.go b/projects/gateway2/proxy_syncer/cla.go index f543119247e..6977ae68acb 100644 --- a/projects/gateway2/proxy_syncer/cla.go +++ b/projects/gateway2/proxy_syncer/cla.go @@ -68,7 +68,10 @@ func (ie *PerClientEnvoyEndpoints) FetchEndpointsForClient(kctx krt.HandlerConte return krt.Fetch(kctx, ie.endpoints, krt.FilterIndex(ie.index, ucc.ResourceName())) } -func NewPerClientEnvoyEndpoints(logger *zap.Logger, krtopts krtutil.KrtOptions, uccs krt.Collection[ir.UniqlyConnectedClient], +func NewPerClientEnvoyEndpoints( + logger *zap.Logger, + krtopts krtutil.KrtOptions, + uccs krt.Collection[ir.UniqlyConnectedClient], glooEndpoints krt.Collection[ir.EndpointsForUpstream], translateEndpoints func(kctx krt.HandlerContext, ucc ir.UniqlyConnectedClient, ep ir.EndpointsForUpstream) (*envoy_config_endpoint_v3.ClusterLoadAssignment, uint64), ) PerClientEnvoyEndpoints { diff --git a/projects/gateway2/proxy_syncer/perclient.go b/projects/gateway2/proxy_syncer/perclient.go index 59307ac5fa1..135cc9ac79d 100644 --- a/projects/gateway2/proxy_syncer/perclient.go +++ b/projects/gateway2/proxy_syncer/perclient.go @@ -11,8 +11,14 @@ import ( "istio.io/istio/pkg/kube/krt" ) -func snapshotPerClient(l *zap.Logger, krtopts krtutil.KrtOptions, uccCol krt.Collection[ir.UniqlyConnectedClient], - mostXdsSnapshots krt.Collection[GatewayXdsResources], endpoints PerClientEnvoyEndpoints, clusters PerClientEnvoyClusters) krt.Collection[XdsSnapWrapper] { +func snapshotPerClient( + l *zap.Logger, + krtopts krtutil.KrtOptions, + uccCol krt.Collection[ir.UniqlyConnectedClient], + mostXdsSnapshots krt.Collection[GatewayXdsResources], + endpoints PerClientEnvoyEndpoints, + clusters PerClientEnvoyClusters, +) krt.Collection[XdsSnapWrapper] { xdsSnapshotsForUcc := krt.NewCollection(uccCol, func(kctx krt.HandlerContext, ucc ir.UniqlyConnectedClient) *XdsSnapWrapper { maybeMostlySnap := krt.FetchOne(kctx, mostXdsSnapshots, krt.FilterKey(ucc.Role)) diff --git a/projects/gateway2/proxy_syncer/proxy_syncer.go b/projects/gateway2/proxy_syncer/proxy_syncer.go index e6be3a9c699..937e837d386 100644 --- a/projects/gateway2/proxy_syncer/proxy_syncer.go +++ b/projects/gateway2/proxy_syncer/proxy_syncer.go @@ -212,9 +212,28 @@ func (s *ProxySyncer) Init(ctx context.Context, isOurGw func(gw *gwv1.Gateway) b return toResources(gw, *xdsSnap, rm) }, krtopts.ToOptions("MostXdsSnapshots")...) - epPerClient := NewPerClientEnvoyEndpoints(logger.Desugar(), krtopts, s.uniqueClients, endpointIRs, s.translatorSyncer.TranslateEndpoints) - clustersPerClient := NewPerClientEnvoyClusters(ctx, krtopts, s.translatorSyncer.GetUpstreamTranslator(), finalUpstreams, s.uniqueClients) - s.perclientSnapCollection = snapshotPerClient(logger.Desugar(), krtopts, s.uniqueClients, s.mostXdsSnapshots, epPerClient, clustersPerClient) + epPerClient := NewPerClientEnvoyEndpoints( + logger.Desugar(), + krtopts, + s.uniqueClients, + endpointIRs, + s.translatorSyncer.TranslateEndpoints, + ) + clustersPerClient := NewPerClientEnvoyClusters( + ctx, + krtopts, + s.translatorSyncer.GetUpstreamTranslator(), + finalUpstreams, + s.uniqueClients, + ) + s.perclientSnapCollection = snapshotPerClient( + logger.Desugar(), + krtopts, + s.uniqueClients, + s.mostXdsSnapshots, + epPerClient, + clustersPerClient, + ) // as proxies are created, they also contain a reportMap containing status for the Gateway and associated xRoutes (really parentRefs) // here we will merge reports that are per-Proxy to a singleton Report used to persist to k8s on a timer diff --git a/projects/gateway2/query/httproute.go b/projects/gateway2/query/httproute.go index 08898d30cbf..33c35a3f65e 100644 --- a/projects/gateway2/query/httproute.go +++ b/projects/gateway2/query/httproute.go @@ -218,7 +218,7 @@ func (r *gatewayQueries) getDelegatedChildren( } ref := *backendRef.Delegate // Fetch child routes based on the backend reference - referencedRoutes, err := r.fetchChildRoutes(kctx, ctx, parent.Namespace, backendRef) + referencedRoutes, err := r.fetchChildRoutes(kctx, backendRef) if err != nil { children.AddError(ref, err) continue @@ -254,8 +254,6 @@ func (r *gatewayQueries) getDelegatedChildren( func (r *gatewayQueries) fetchChildRoutes( kctx krt.HandlerContext, - ctx context.Context, - parentNamespace string, backend ir.HttpBackendOrDelegate, ) ([]ir.HttpRouteIR, error) { @@ -294,7 +292,7 @@ func (r *gatewayQueries) GetRoutesForGateway(kctx krt.HandlerContext, ctx contex // Process each route ret := NewRoutesForGwResult() - routes := fetchRoutes(kctx, r, nns) + routes := r.routes.RoutesForGateway(kctx, nns) for _, route := range routes { if err := r.processRoute(kctx, ctx, gw, route, ret); err != nil { return nil, err @@ -304,14 +302,13 @@ func (r *gatewayQueries) GetRoutesForGateway(kctx krt.HandlerContext, ctx contex return ret, nil } -// fetchRoutes is a helper function to fetch routes and add to the routes slice. -func fetchRoutes(kctx krt.HandlerContext, r *gatewayQueries, nns types.NamespacedName) []ir.Route { - return r.routes.RoutesForGateway(kctx, nns) -} - func (r *gatewayQueries) processRoute( kctx krt.HandlerContext, - ctx context.Context, gw *gwv1.Gateway, route ir.Route, ret *RoutesForGwResult) error { + ctx context.Context, + gw *gwv1.Gateway, + route ir.Route, + ret *RoutesForGwResult, +) error { refs := getParentRefsForGw(gw, route) routeKind := route.GetGroupKind().Kind diff --git a/projects/gateway2/query/query.go b/projects/gateway2/query/query.go index 5c2d10fc5cc..d7973ca4149 100644 --- a/projects/gateway2/query/query.go +++ b/projects/gateway2/query/query.go @@ -97,20 +97,6 @@ func (f FromObject) Namespace() string { return f.GetNamespace() } -// TODO(Law): remove this type entirely? -type FromGkNs struct { - Gk metav1.GroupKind - Ns string -} - -func (f FromGkNs) GroupKind() (metav1.GroupKind, error) { - return f.Gk, nil -} - -func (f FromGkNs) Namespace() string { - return f.Ns -} - type GatewayQueries interface { GetSecretForRef(kctx krt.HandlerContext, ctx context.Context, fromGk schema.GroupKind, fromns string, secretRef apiv1.SecretObjectReference) (*ir.Secret, error) @@ -121,7 +107,8 @@ type GatewayQueries interface { ctx context.Context, route ir.Route, hostnames []string, - parentRef gwv1.ParentReference) *RouteInfo + parentRef gwv1.ParentReference, + ) *RouteInfo } type RoutesForGwResult struct { diff --git a/projects/gateway2/setup/ggv2setup.go b/projects/gateway2/setup/ggv2setup.go index 1b20124975f..810d64fdd92 100644 --- a/projects/gateway2/setup/ggv2setup.go +++ b/projects/gateway2/setup/ggv2setup.go @@ -125,12 +125,6 @@ func StartGGv2WithConfig(ctx context.Context, setupOpts *controller.SetupOpts, krtOpts := krtutil.NewKrtOptions(ctx.Done(), setupOpts.KrtDebugger) augmentedPods := krtcollections.NewPodsCollection(kubeClient, krtOpts) - setting := krtutil.SetupCollectionDynamic[glookubev1.Settings]( - ctx, - kubeClient, - settingsGVR, - krt.WithName("GlooSettings")) - augmentedPodsForUcc := augmentedPods if envutils.IsEnvTruthy("DISABLE_POD_LOCALITY_XDS") { augmentedPodsForUcc = nil @@ -138,6 +132,11 @@ func StartGGv2WithConfig(ctx context.Context, setupOpts *controller.SetupOpts, ucc := uccBuilder(ctx, krtOpts, augmentedPodsForUcc) + setting := krtutil.SetupCollectionDynamic[glookubev1.Settings]( + ctx, + kubeClient, + settingsGVR, + krt.WithName("GlooSettings")) settingsSingle := krt.NewSingleton(func(ctx krt.HandlerContext) *glookubev1.Settings { s := krt.FetchOne(ctx, setting, krt.FilterObjectName(settingsNns)) @@ -147,10 +146,7 @@ func StartGGv2WithConfig(ctx context.Context, setupOpts *controller.SetupOpts, return nil }, krt.WithName("GlooSettingsSingleton")) - logger.Info("creating reporter") - logger.Info("initializing controller") - c, err := controller.NewControllerBuilder(ctx, controller.StartConfig{ ExtraPlugins: extraPlugins, RestConfig: restConfig, diff --git a/projects/gateway2/translator/irtranslator/upstream.go b/projects/gateway2/translator/irtranslator/upstream.go index 8cee3b7bbf0..d4a7648ce32 100644 --- a/projects/gateway2/translator/irtranslator/upstream.go +++ b/projects/gateway2/translator/irtranslator/upstream.go @@ -20,7 +20,11 @@ type UpstreamTranslator struct { ContributedPolicies map[schema.GroupKind]extensionsplug.PolicyPlugin } -func (t *UpstreamTranslator) TranslateUpstream(kctx krt.HandlerContext, ucc ir.UniqlyConnectedClient, u ir.Upstream) (*envoy_config_cluster_v3.Cluster, error) { +func (t *UpstreamTranslator) TranslateUpstream( + kctx krt.HandlerContext, + ucc ir.UniqlyConnectedClient, + u ir.Upstream, +) (*envoy_config_cluster_v3.Cluster, error) { gk := schema.GroupKind{ Group: u.Group, Kind: u.Kind, diff --git a/projects/gateway2/translator/listener/gateway_listener_translator.go b/projects/gateway2/translator/listener/gateway_listener_translator.go index d2ead3cb051..9c650f96421 100644 --- a/projects/gateway2/translator/listener/gateway_listener_translator.go +++ b/projects/gateway2/translator/listener/gateway_listener_translator.go @@ -157,7 +157,6 @@ func (ml *MergedListeners) appendHttpsListener( sniDomain: listener.Hostname, tls: listener.TLS, routesWithHosts: routesWithHosts, - queries: ml.Queries, attachedPolicies: listener.AttachedPolicies, } @@ -573,7 +572,6 @@ type httpsFilterChain struct { sniDomain *gwv1.Hostname tls *gwv1.GatewayTLSConfig routesWithHosts []*query.RouteInfo - queries query.GatewayQueries attachedPolicies ir.AttachedPolicies } diff --git a/projects/gateway2/translator/translator.go b/projects/gateway2/translator/translator.go index 683240d4a1e..5ac8d706dfa 100644 --- a/projects/gateway2/translator/translator.go +++ b/projects/gateway2/translator/translator.go @@ -144,9 +144,9 @@ func (s *CombinedTranslator) GetUpstreamTranslator() *irtranslator.UpstreamTrans func (s *CombinedTranslator) TranslateGateway(kctx krt.HandlerContext, ctx context.Context, gw ir.Gateway) (*irtranslator.TranslationResult, reports.ReportMap) { logger := contextutils.LoggerFrom(ctx) - logger.Debugf("building proxy for kube gw %s version %s", client.ObjectKeyFromObject(gw.Obj), gw.Obj.GetResourceVersion()) rm := reports.NewReportMap() r := reports.NewReporter(&rm) + logger.Debugf("building proxy for kube gw %s version %s", client.ObjectKeyFromObject(gw.Obj), gw.Obj.GetResourceVersion()) gwir := s.buildProxy(kctx, ctx, gw, r) if gwir == nil {