Skip to content

Commit

Permalink
fix: Skip InferenceService patching for KServe RawDeployment (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira authored Jul 29, 2024
1 parent 4a52d65 commit ec4462e
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions controllers/inference_services.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ import (
"strings"
)

const (
DEPLOYMENT_MODE_MODELMESH = "ModelMesh"
DEPLOYMENT_MODE_RAW = "RawDeployment"
DEPLOYMENT_MODE_SERVERLESS = "Serverless"
)

func (r *TrustyAIServiceReconciler) patchEnvVarsForDeployments(ctx context.Context, instance *trustyaiopendatahubiov1alpha1.TrustyAIService, deployments []appsv1.Deployment, envVarName string, url string, remove bool) (bool, error) {
// Create volume and volume mount for this intance's TLS secrets
certVolumes := TLSCertVolumes{}
Expand Down Expand Up @@ -199,20 +205,26 @@ func (r *TrustyAIServiceReconciler) handleInferenceServices(ctx context.Context,

for _, infService := range inferenceServices.Items {
annotations := infService.GetAnnotations()
// Check the annotation "serving.kserve.io/deploymentMode: ModelMesh"
if val, ok := annotations["serving.kserve.io/deploymentMode"]; ok && val == "ModelMesh" {
shouldContinue, err := r.patchEnvVarsByLabelForDeployments(ctx, instance, namespace, labelKey, labelValue, envVarName, crName, remove)
if err != nil {
log.FromContext(ctx).Error(err, "Could not patch environment variables for ModelMesh deployments.")
return shouldContinue, err
}
} else {
err := r.patchKServe(ctx, instance, infService, namespace, crName, remove)
if err != nil {
log.FromContext(ctx).Error(err, "Could not path InferenceLogger for KServe deployment.")
return false, err

// Check the annotation "serving.kserve.io/deploymentMode"
if val, ok := annotations["serving.kserve.io/deploymentMode"]; ok {
if val == DEPLOYMENT_MODE_RAW {
log.FromContext(ctx).Info("RawDeployment mode not supported by TrustyAI")
continue
} else if val == DEPLOYMENT_MODE_MODELMESH {
shouldContinue, err := r.patchEnvVarsByLabelForDeployments(ctx, instance, namespace, labelKey, labelValue, envVarName, crName, remove)
if err != nil {
log.FromContext(ctx).Error(err, "could not patch environment variables for ModelMesh deployments")
return shouldContinue, err
}
continue
}
}
err := r.patchKServe(ctx, instance, infService, namespace, crName, remove)
if err != nil {
log.FromContext(ctx).Error(err, "could not patch InferenceLogger for KServe deployment")
return false, err
}
}
return true, nil
}
Expand Down

0 comments on commit ec4462e

Please sign in to comment.