Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into switch-to-proxy-syncer
Browse files Browse the repository at this point in the history
  • Loading branch information
npolshakova committed Apr 11, 2024
2 parents 30abdd4 + 2ae5cfb commit b7fe1a9
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 19 deletions.
6 changes: 6 additions & 0 deletions changelog/v1.17.0-beta19/gg-plugin-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: NON_USER_FACING
issueLink: https://github.com/solo-io/solo-projects/issues/5934
resolvesIssue: false
description: >-
Move objects needed for construction of OSS GGv2 plugins to a param object
2 changes: 1 addition & 1 deletion projects/gateway2/controller/controller_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ var _ = BeforeSuite(func() {

var gatewayClassObjName api.ObjectName = api.ObjectName(gatewayClassName)

exts, err := extensions.NewK8sGatewayExtensions(mgr, nil, nil)
exts, err := extensions.NewK8sGatewayExtensions(mgr)
Expect(err).ToNot(HaveOccurred())
cfg := controller.GatewayConfig{
Mgr: mgr,
Expand Down
4 changes: 3 additions & 1 deletion projects/gateway2/controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func Start(ctx context.Context, cfg StartConfig) error {

inputChannels := proxy_syncer.NewGatewayInputChannels()

k8sGwExtensions, err := cfg.ExtensionsFactory(mgr, cfg.RouteOptionClient, cfg.StatusReporter)
k8sGwExtensions, err := cfg.ExtensionsFactory(mgr)
if err != nil {
setupLog.Error(err, "unable to create k8s gw extensions")
return err
Expand All @@ -106,6 +106,8 @@ func Start(ctx context.Context, cfg StartConfig) error {
mgr,
k8sGwExtensions,
cfg.ProxyClient,
cfg.RouteOptionClient,
cfg.StatusReporter,
)
if err := mgr.Add(proxySyncer); err != nil {
setupLog.Error(err, "unable to add proxySyncer runnable")
Expand Down
6 changes: 3 additions & 3 deletions projects/gateway2/deployer/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ var _ = Describe("Deployer", func() {
}
mgr, err := ctrl.NewManager(&rest.Config{}, ctrl.Options{})
Expect(err).NotTo(HaveOccurred())
k8sGatewayExt, err = extensions.NewK8sGatewayExtensions(mgr, nil, nil)
k8sGatewayExt, err = extensions.NewK8sGatewayExtensions(mgr)
Expect(err).NotTo(HaveOccurred())

})
Expand Down Expand Up @@ -151,7 +151,7 @@ var _ = Describe("Deployer", func() {
It("support segmenting by release", func() {
mgr, err := ctrl.NewManager(&rest.Config{}, ctrl.Options{})
Expect(err).NotTo(HaveOccurred())
k8sGatewayExt, err := extensions.NewK8sGatewayExtensions(mgr, nil, nil)
k8sGatewayExt, err := extensions.NewK8sGatewayExtensions(mgr)
Expect(err).NotTo(HaveOccurred())

d1, err := deployer.NewDeployer(newFakeClientWithObjs(gwc), &deployer.Inputs{
Expand Down Expand Up @@ -252,7 +252,7 @@ var _ = Describe("Deployer", func() {
defaultDeployerInputs = func() *deployer.Inputs {
mgr, err := ctrl.NewManager(&rest.Config{}, ctrl.Options{})
Expect(err).NotTo(HaveOccurred())
k8sGatewayExt, err := extensions.NewK8sGatewayExtensions(mgr, nil, nil)
k8sGatewayExt, err := extensions.NewK8sGatewayExtensions(mgr)
Expect(err).NotTo(HaveOccurred())
return &deployer.Inputs{
ControllerName: wellknown.GatewayControllerName,
Expand Down
23 changes: 10 additions & 13 deletions projects/gateway2/extensions/extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,46 @@ import (
// which have Enterprise variants.
type K8sGatewayExtensions interface {
// CreatePluginRegistry returns the PluginRegistry
CreatePluginRegistry(ctx context.Context) registry.PluginRegistry
CreatePluginRegistry(ctx context.Context, params PluginBuilderParams) registry.PluginRegistry

// GetEnvoyImage returns the envoy image and tag used by the proxy deployment.
GetEnvoyImage() Image
}

type PluginBuilderParams struct {
RouteOptionClient gatewayv1.RouteOptionClient
StatusReporter reporter.StatusReporter
}

// K8sGatewayExtensionsFactory returns an extensions.K8sGatewayExtensions
type K8sGatewayExtensionsFactory func(
mgr controllerruntime.Manager,
routeOptionClient gatewayv1.RouteOptionClient,
statusReporter reporter.StatusReporter,
) (K8sGatewayExtensions, error)

// NewK8sGatewayExtensions returns the Open Source implementation of K8sGatewayExtensions
func NewK8sGatewayExtensions(
mgr controllerruntime.Manager,
routeOptionClient gatewayv1.RouteOptionClient,
statusReporter reporter.StatusReporter,
) (K8sGatewayExtensions, error) {
return &k8sGatewayExtensions{
mgr,
routeOptionClient,
statusReporter,
}, nil
}

type k8sGatewayExtensions struct {
mgr controllerruntime.Manager
routeOptionClient gatewayv1.RouteOptionClient
statusReporter reporter.StatusReporter
mgr controllerruntime.Manager
}

// CreatePluginRegistry returns the PluginRegistry
func (e *k8sGatewayExtensions) CreatePluginRegistry(_ context.Context) registry.PluginRegistry {
func (e *k8sGatewayExtensions) CreatePluginRegistry(_ context.Context, params PluginBuilderParams) registry.PluginRegistry {
queries := query.NewData(
e.mgr.GetClient(),
e.mgr.GetScheme(),
)
plugins := registry.BuildPlugins(
queries,
e.mgr.GetClient(),
e.routeOptionClient,
e.statusReporter,
params.RouteOptionClient,
params.StatusReporter,
)
return registry.NewPluginRegistry(plugins)
}
Expand Down
13 changes: 12 additions & 1 deletion projects/gateway2/proxy_syncer/proxy_syncer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package proxy_syncer
import (
"context"

gatewayv1 "github.com/solo-io/gloo/projects/gateway/pkg/api/v1"
"github.com/solo-io/solo-kit/pkg/api/v2/reporter"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"
apiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down Expand Up @@ -34,6 +36,9 @@ type ProxySyncer struct {
// proxyReconciler wraps the client that writes Proxy resources into an in-memory cache
// This cache is utilized by the debug.ProxyEndpointServer
proxyReconciler gloo_solo_io.ProxyReconciler

routeOptionClient gatewayv1.RouteOptionClient
statusReporter reporter.StatusReporter
}

type GatewayInputChannels struct {
Expand Down Expand Up @@ -63,6 +68,8 @@ func NewProxySyncer(
mgr manager.Manager,
k8sGwExtensions extensions.K8sGatewayExtensions,
proxyClient gloo_solo_io.ProxyClient,
routeOptionClient gatewayv1.RouteOptionClient,
statusReporter reporter.StatusReporter,
) *ProxySyncer {
return &ProxySyncer{
controllerName: controllerName,
Expand Down Expand Up @@ -97,7 +104,11 @@ func (s *ProxySyncer) Start(ctx context.Context) error {

gatewayQueries := query.NewData(s.mgr.GetClient(), s.mgr.GetScheme())

pluginRegistry := s.k8sGwExtensions.CreatePluginRegistry(ctx)
pluginParams := extensions.PluginBuilderParams{
RouteOptionClient: s.routeOptionClient,
StatusReporter: s.statusReporter,
}
pluginRegistry := s.k8sGwExtensions.CreatePluginRegistry(ctx, pluginParams)
gatewayTranslator := gwv2_translator.NewTranslator(gatewayQueries, pluginRegistry)

rm := reports.NewReportMap()
Expand Down

0 comments on commit b7fe1a9

Please sign in to comment.