Skip to content

Commit

Permalink
[v0.11.1] Fix controller setup - add schemas based on CRDs available
Browse files Browse the repository at this point in the history
In opendatahub-io#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>
  • Loading branch information
israel-hdez committed Mar 7, 2024
1 parent b9db212 commit a1fbd38
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.")
}
Expand All @@ -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")
Expand Down

0 comments on commit a1fbd38

Please sign in to comment.