Skip to content

Commit

Permalink
fix: Use correct ConfigMap for orchestrator image config (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
ruivieira authored Feb 18, 2025
1 parent 70cd5c7 commit bf9d8fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions controllers/gorch/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ func (r *GuardrailsOrchestratorReconciler) getImageFromConfigMap(ctx context.Con
err := r.Get(ctx, types.NamespacedName{Name: configMapName, Namespace: namespace}, configMap)
if err != nil {
if errors.IsNotFound(err) {
return "", nil
return "", fmt.Errorf("could not find configmap %s on namespace %s", configMapName, namespace)
}
return "", fmt.Errorf("error reading configmap %s", configMapName)
return "", fmt.Errorf("error reading configmap %s on namespace %s", configMapName, namespace)
}

containerImage, ok := configMap.Data[configMapKey]

if !ok {
return "", fmt.Errorf("configmap %s does not contain necessary keys", configMapName)
return "", fmt.Errorf("configmap %s on namespace %s does not contain necessary keys", configMapName, namespace)
}
return containerImage, nil
}
9 changes: 6 additions & 3 deletions controllers/gorch/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,26 @@ type DeploymentConfig struct {
func (r *GuardrailsOrchestratorReconciler) createDeployment(ctx context.Context, orchestrator *gorchv1alpha1.GuardrailsOrchestrator) *appsv1.Deployment {
var containerImages ContainerImages
// Get orchestrator image
orchestratorConfigMapName := orchestrator.Name + "-config"
orchestratorImage, err := r.getImageFromConfigMap(ctx, orchestratorImageKey, constants.ConfigMap, r.Namespace)
if orchestratorImage == "" || err != nil {
log.FromContext(ctx).Error(err, "Error getting container image from ConfigMap.")
}
containerImages.OrchestratorImage = orchestratorImage

log.FromContext(ctx).Info("using orchestratorImage " + orchestratorImage + "from config map " + r.Namespace + ":" + constants.ConfigMap)
// Check if the vLLM gateway is enabled
if orchestrator.Spec.VLLMGatewayConfig != nil {
// Get the gateway and regex detector container images
vllmGatewayImage, err := r.getImageFromConfigMap(ctx, vllmGatewayImageKey, orchestratorName+"-config", orchestrator.Namespace)
vllmGatewayImage, err := r.getImageFromConfigMap(ctx, vllmGatewayImageKey, orchestratorConfigMapName, orchestrator.Namespace)
if vllmGatewayImage == "" || err != nil {
log.FromContext(ctx).Error(err, "Error getting vLLM gateway image from ConfigMap.")
}
regexDetectorImage, err := r.getImageFromConfigMap(ctx, regexDetectorImageKey, orchestratorName+"-config", orchestrator.Namespace)
log.FromContext(ctx).Info("using vLLM gateway image " + vllmGatewayImage + "from config map " + orchestrator.Namespace + ":" + orchestratorConfigMapName)
regexDetectorImage, err := r.getImageFromConfigMap(ctx, regexDetectorImageKey, orchestratorConfigMapName, orchestrator.Namespace)
if regexDetectorImage == "" || err != nil {
log.FromContext(ctx).Error(err, "Error getting regex detectors image from ConfigMap.")
}
log.FromContext(ctx).Info("using regex detectors image " + regexDetectorImage + "from config map " + orchestrator.Namespace + ":" + orchestratorConfigMapName)
containerImages.GatewayImage = vllmGatewayImage
containerImages.RegexDetectorImage = regexDetectorImage
}
Expand Down

0 comments on commit bf9d8fd

Please sign in to comment.