From 932a60545443f7117db6ae9f65a79c1403457864 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Hern=C3=A1ndez?= <23639005+israel-hdez@users.noreply.github.com> Date: Thu, 7 Mar 2024 11:49:41 -0600 Subject: [PATCH] [v0.11.1] Fix controller setup - add schemas based on CRDs available MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In #233 an enhancement was done to KServe controllers to watch resources based on available CRDs. A similar change in the setup of the manager was overlooked: it is also needed to add schemas to the manager based on available CRDs rather than only the values in the inferenceservice-config ConfigMap. This would keep both manager setup and controller setup in sync with regards schemas and watches around the CRDs. Signed-off-by: Edgar Hernández <23639005+israel-hdez@users.noreply.github.com> --- cmd/manager/main.go | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index ab3101a0c0..471e5e90cd 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -27,6 +27,7 @@ import ( trainedmodelcontroller "github.com/kserve/kserve/pkg/controller/v1alpha1/trainedmodel" "github.com/kserve/kserve/pkg/controller/v1alpha1/trainedmodel/reconcilers/modelconfig" v1beta1controller "github.com/kserve/kserve/pkg/controller/v1beta1/inferenceservice" + "github.com/kserve/kserve/pkg/utils" "github.com/kserve/kserve/pkg/webhook/admission/pod" "github.com/kserve/kserve/pkg/webhook/admission/servingruntime" istio_networking "istio.io/api/networking/v1alpha3" @@ -131,7 +132,7 @@ func main() { os.Exit(1) } - client, err := client.New(mgr.GetConfig(), client.Options{Scheme: mgr.GetScheme()}) + client, err := client.New(cfg, client.Options{Scheme: mgr.GetScheme()}) if err != nil { log.Error(err, "unable to create new client.") } @@ -146,13 +147,27 @@ func main() { log.Error(err, "unable to get ingress config.") os.Exit(1) } - if deployConfig.DefaultDeploymentMode == string(constants.Serverless) { + + ksvcFound, ksvcCheckErr := utils.IsCrdAvailable(cfg, knservingv1.SchemeGroupVersion.String(), constants.KnativeServiceKind) + if ksvcCheckErr != nil { + log.Error(ksvcCheckErr, "error when checking if Knative Service kind is available") + os.Exit(1) + } + if ksvcFound { log.Info("Setting up Knative scheme") if err := knservingv1.AddToScheme(mgr.GetScheme()); err != nil { log.Error(err, "unable to add Knative APIs to scheme") os.Exit(1) } - if ingressConfig.DisableIstioVirtualHost == false { + } + + if !ingressConfig.DisableIstioVirtualHost { + vsFound, vsCheckErr := utils.IsCrdAvailable(cfg, v1alpha3.SchemeGroupVersion.String(), constants.IstioVirtualServiceKind) + if vsCheckErr != nil { + log.Error(vsCheckErr, "error when checking if Istio VirtualServices are available") + os.Exit(1) + } + if vsFound { log.Info("Setting up Istio schemes") if err := v1alpha3.AddToScheme(mgr.GetScheme()); err != nil { log.Error(err, "unable to add Istio v1alpha3 APIs to scheme")