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

fix CRDExists check #10353

Merged
merged 3 commits into from
Nov 14, 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
4 changes: 4 additions & 0 deletions changelog/v1.18.0-beta35/crdcheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: NON_USER_FACING
description: >-
Fix CRD check to allow the group/kind to be missing.
3 changes: 2 additions & 1 deletion pkg/schemes/extended_scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
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 @@ -151,6 +151,8 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
krt.WithName("AuthConfig"))

inputChannels := proxy_syncer.NewGatewayInputChannels()

setupLog.Info("initializing k8sgateway extensions")
k8sGwExtensions, err := cfg.ExtensionsFactory(ctx, ext.K8sGatewayExtensionsFactoryParameters{
Mgr: mgr,
IstioClient: cfg.Client,
Expand All @@ -169,6 +171,7 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
}

// Create the proxy syncer for the Gateway API resources
setupLog.Info("initializing proxy syncer")
proxySyncer := proxy_syncer.NewProxySyncer(
ctx,
cfg.InitialSettings,
Expand All @@ -188,7 +191,6 @@ func NewControllerBuilder(ctx context.Context, cfg StartConfig) (*ControllerBuil
cfg.SetupOpts.ProxyReconcileQueue,
)
proxySyncer.Init(ctx, cfg.Debugger)

if err := mgr.Add(proxySyncer); err != nil {
setupLog.Error(err, "unable to add proxySyncer runnable")
return nil, err
Expand Down
13 changes: 5 additions & 8 deletions projects/gateway2/setup/ggv2setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -164,6 +160,7 @@ func StartGGv2WithConfig(ctx context.Context,
Debugger: setupOpts.KrtDebugger,
})
if err != nil {
logger.Error("failed initializing controller: ", err)
return err
}
/// no collections after this point
Expand Down
Loading