From af22b6c21834f712c090e574a12481b419cf4c6d Mon Sep 17 00:00:00 2001 From: Steven Landow Date: Thu, 14 Nov 2024 10:49:37 -0800 Subject: [PATCH 1/2] fix CRDExists check --- pkg/schemes/extended_scheme.go | 3 ++- projects/gateway2/controller/start.go | 4 ++++ projects/gateway2/setup/ggv2setup.go | 13 +++++-------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/schemes/extended_scheme.go b/pkg/schemes/extended_scheme.go index 0e4cc557d98..69aaf372b86 100644 --- a/pkg/schemes/extended_scheme.go +++ b/pkg/schemes/extended_scheme.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/solo-io/gloo/projects/gateway2/wellknown" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/discovery" @@ -38,7 +39,7 @@ func CRDExists(restConfig *rest.Config, group, version, kind string) (bool, erro groupVersion := fmt.Sprintf("%s/%s", group, version) apiResourceList, err := discoveryClient.ServerResourcesForGroupVersion(groupVersion) if err != nil { - if discovery.IsGroupDiscoveryFailedError(err) || meta.IsNoMatchError(err) { + if errors.IsNotFound(err) || discovery.IsGroupDiscoveryFailedError(err) || meta.IsNoMatchError(err) { return false, nil } return false, err diff --git a/projects/gateway2/controller/start.go b/projects/gateway2/controller/start.go index 787ee182c07..cbfdc45ef20 100644 --- a/projects/gateway2/controller/start.go +++ b/projects/gateway2/controller/start.go @@ -151,6 +151,7 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil krt.WithName("AuthConfig")) inputChannels := proxy_syncer.NewGatewayInputChannels() + setupLog.Info("setting up k8s gw ext") k8sGwExtensions, err := cfg.ExtensionsFactory(ctx, ext.K8sGatewayExtensionsFactoryParameters{ Mgr: mgr, IstioClient: cfg.Client, @@ -168,6 +169,7 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil return nil, err } + setupLog.Info("setting proxy syncer") // Create the proxy syncer for the Gateway API resources proxySyncer := proxy_syncer.NewProxySyncer( ctx, @@ -187,8 +189,10 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil cfg.GlooStatusReporter, cfg.SetupOpts.ProxyReconcileQueue, ) + setupLog.Info("init proxy syncer") proxySyncer.Init(ctx, cfg.Debugger) + setupLog.Info("register proxy syncer") if err := mgr.Add(proxySyncer); err != nil { setupLog.Error(err, "unable to add proxySyncer runnable") return nil, err diff --git a/projects/gateway2/setup/ggv2setup.go b/projects/gateway2/setup/ggv2setup.go index 8f2f1300244..673ea768b08 100644 --- a/projects/gateway2/setup/ggv2setup.go +++ b/projects/gateway2/setup/ggv2setup.go @@ -2,12 +2,11 @@ package setup import ( "context" + "errors" "fmt" "sort" "strings" - "errors" - "github.com/solo-io/gloo/pkg/utils/envutils" "github.com/solo-io/gloo/pkg/utils/setuputils" gloostatusutils "github.com/solo-io/gloo/pkg/utils/statusutils" @@ -43,9 +42,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" ) -var ( - settingsGVR = glookubev1.SchemeGroupVersion.WithResource("settings") -) +var settingsGVR = glookubev1.SchemeGroupVersion.WithResource("settings") func createKubeClient(restConfig *rest.Config) (istiokube.Client, error) { restCfg := istiokube.NewClientConfigForRestConfig(restConfig) @@ -77,15 +74,14 @@ func getInitialSettings(ctx context.Context, c istiokube.Client, nns types.Names return nil } return out - } func StartGGv2(ctx context.Context, setupOpts *bootstrap.SetupOpts, uccBuilder krtcollections.UniquelyConnectedClientsBulider, extensionsFactory extensions.K8sGatewayExtensionsFactory, - pluginRegistryFactory func(opts registry.PluginOpts) plugins.PluginRegistryFactory) error { - + pluginRegistryFactory func(opts registry.PluginOpts) plugins.PluginRegistryFactory, +) error { restConfig := ctrl.GetConfigOrDie() return StartGGv2WithConfig(ctx, setupOpts, restConfig, uccBuilder, extensionsFactory, pluginRegistryFactory, setuputils.SetupNamespaceName()) @@ -164,6 +160,7 @@ func StartGGv2WithConfig(ctx context.Context, Debugger: setupOpts.KrtDebugger, }) if err != nil { + logger.Error("failed building controller: ", err) return err } /// no collections after this point From 5bc8a0a77237f86afdcee2b44f27ad26e362dff1 Mon Sep 17 00:00:00 2001 From: Steven Landow Date: Thu, 14 Nov 2024 12:32:06 -0800 Subject: [PATCH 2/2] changelog --- changelog/v1.18.0-beta35/crdcheck.yaml | 4 ++++ projects/gateway2/controller/start.go | 8 +++----- projects/gateway2/setup/ggv2setup.go | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 changelog/v1.18.0-beta35/crdcheck.yaml diff --git a/changelog/v1.18.0-beta35/crdcheck.yaml b/changelog/v1.18.0-beta35/crdcheck.yaml new file mode 100644 index 00000000000..c50b01d981f --- /dev/null +++ b/changelog/v1.18.0-beta35/crdcheck.yaml @@ -0,0 +1,4 @@ +changelog: + - type: NON_USER_FACING + description: >- + Fix CRD check to allow the group/kind to be missing. diff --git a/projects/gateway2/controller/start.go b/projects/gateway2/controller/start.go index cbfdc45ef20..e9f7efd63ab 100644 --- a/projects/gateway2/controller/start.go +++ b/projects/gateway2/controller/start.go @@ -151,7 +151,8 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil krt.WithName("AuthConfig")) inputChannels := proxy_syncer.NewGatewayInputChannels() - setupLog.Info("setting up k8s gw ext") + + setupLog.Info("initializing k8sgateway extensions") k8sGwExtensions, err := cfg.ExtensionsFactory(ctx, ext.K8sGatewayExtensionsFactoryParameters{ Mgr: mgr, IstioClient: cfg.Client, @@ -169,8 +170,8 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil return nil, err } - setupLog.Info("setting proxy syncer") // Create the proxy syncer for the Gateway API resources + setupLog.Info("initializing proxy syncer") proxySyncer := proxy_syncer.NewProxySyncer( ctx, cfg.InitialSettings, @@ -189,10 +190,7 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil cfg.GlooStatusReporter, cfg.SetupOpts.ProxyReconcileQueue, ) - setupLog.Info("init proxy syncer") proxySyncer.Init(ctx, cfg.Debugger) - - setupLog.Info("register proxy syncer") if err := mgr.Add(proxySyncer); err != nil { setupLog.Error(err, "unable to add proxySyncer runnable") return nil, err diff --git a/projects/gateway2/setup/ggv2setup.go b/projects/gateway2/setup/ggv2setup.go index 673ea768b08..e0bea7e7661 100644 --- a/projects/gateway2/setup/ggv2setup.go +++ b/projects/gateway2/setup/ggv2setup.go @@ -160,7 +160,7 @@ func StartGGv2WithConfig(ctx context.Context, Debugger: setupOpts.KrtDebugger, }) if err != nil { - logger.Error("failed building controller: ", err) + logger.Error("failed initializing controller: ", err) return err } /// no collections after this point