Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions internal/controller/appserver/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package appserver

import (
"context"
"crypto/sha256"
"encoding/json"
"fmt"
"path"
Expand Down Expand Up @@ -466,6 +467,7 @@ func GenerateOLSDeployment(r reconciler.Reconciler, cr *olsv1alpha1.OLSConfig) (

annotations := map[string]string{
utils.OLSConfigMapResourceVersionAnnotation: configMapResourceVersion,
utils.RAGSpecHashAnnotation: ragSpecHash(cr),
utils.ProxyCACertHashAnnotation: proxyCACMResourceVersion,
}

Expand Down Expand Up @@ -616,6 +618,13 @@ func updateOLSDeployment(r reconciler.Reconciler, ctx context.Context, cr *olsv1
}
}

// Step 4: Check if RAG spec has changed
currentRAGHash := ragSpecHash(cr)
if existingDeployment.Annotations[utils.RAGSpecHashAnnotation] != currentRAGHash {
r.GetLogger().Info("RAG spec changed, updating deployment")
changed = true
}

// If nothing changed, skip update
if !changed {
return nil
Expand All @@ -630,6 +639,7 @@ func updateOLSDeployment(r reconciler.Reconciler, ctx context.Context, cr *olsv1
}

existingDeployment.Annotations[utils.OLSConfigMapResourceVersionAnnotation] = desiredDeployment.Annotations[utils.OLSConfigMapResourceVersionAnnotation]
existingDeployment.Annotations[utils.RAGSpecHashAnnotation] = currentRAGHash
existingDeployment.Annotations[utils.ProxyCACertHashAnnotation] = currentProxyCACMHash

r.GetLogger().Info("updating OLS deployment", "name", existingDeployment.Name)
Expand Down Expand Up @@ -733,3 +743,11 @@ func RestartAppServer(r reconciler.Reconciler, ctx context.Context, deployment .

return nil
}

func ragSpecHash(cr *olsv1alpha1.OLSConfig) string {
if len(cr.Spec.OLSConfig.RAG) == 0 {
return ""
}
data, _ := json.Marshal(cr.Spec.OLSConfig.RAG)
return fmt.Sprintf("%x", sha256.Sum256(data))
}
2 changes: 2 additions & 0 deletions internal/controller/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ ssl_ca_file = '/etc/certs/cm-olspostgresca/service-ca.crt'
OpenShiftMCPServerConfigMapResourceVersionAnnotation = "ols.openshift.io/mcp-server-configmap-version"
// OpenShiftMCPServerTLSSecretResourceVersionAnnotation tracks the MCP TLS Secret ResourceVersion on the MCP Deployment.
OpenShiftMCPServerTLSSecretResourceVersionAnnotation = "ols.openshift.io/mcp-server-tls-secret-version" // #nosec G101
// RAGSpecHashAnnotation tracks the hash of .spec.ols.rag on the app-server Deployment.
RAGSpecHashAnnotation = "ols.openshift.io/rag-spec-hash"

/*** Standalone RHOKP Constants ***/
// RHOKPDeploymentName is the Deployment name for the standalone RHOKP operand.
Expand Down