From dc2991cb0ea9870d0baffc99a58b771818b3e12f Mon Sep 17 00:00:00 2001 From: Andrei Pavlov Date: Wed, 30 Oct 2024 14:05:36 +0700 Subject: [PATCH] Fix race caused by Scheme update Signed-off-by: Andrei Pavlov --- internal/certmanager/verifier.go | 3 ++- internal/controller/management_controller.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/certmanager/verifier.go b/internal/certmanager/verifier.go index 75b9f903e..e41e192fc 100644 --- a/internal/certmanager/verifier.go +++ b/internal/certmanager/verifier.go @@ -22,7 +22,8 @@ import ( "k8s.io/client-go/rest" ) -func VerifyAPI(ctx context.Context, restcfg *rest.Config, scheme *runtime.Scheme, namespace string) error { +func VerifyAPI(ctx context.Context, restcfg *rest.Config, namespace string) error { + scheme := runtime.NewScheme() checker, err := cmapichecker.New(restcfg, scheme, namespace) if err != nil { return err diff --git a/internal/controller/management_controller.go b/internal/controller/management_controller.go index c2b4e2c5b..5d4b324a9 100644 --- a/internal/controller/management_controller.go +++ b/internal/controller/management_controller.go @@ -384,7 +384,7 @@ func (r *ManagementReconciler) enableAdditionalComponents(ctx context.Context, m capiOperatorValues = v } - err := certmanager.VerifyAPI(ctx, r.Config, r.Scheme, r.SystemNamespace) + err := certmanager.VerifyAPI(ctx, r.Config, r.SystemNamespace) if err != nil { return fmt.Errorf("failed to check in the cert-manager API is installed: %v", err) }