Skip to content

Commit ad3c68c

Browse files
Ambient Code Botclaude
andcommitted
fix(operator): scope SA token automount to kubernetes-namespaced auth only
- Only enable ServiceAccount token automount and per-session SA when MLFLOW_TRACKING_AUTH is "kubernetes-namespaced" (read from the copied secret), not for all MLflow-secret sessions. This avoids granting an unnecessary namespace-scoped token to sessions using other auth methods. - Remove duplicate MLFLOW_TRACKING_AUTH env var entry. Addresses CodeRabbit review on PR #1263. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8d0e56c commit ad3c68c

1 file changed

Lines changed: 5 additions & 11 deletions

File tree

components/operator/internal/handlers/sessions.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,7 @@ func handleAgenticSessionEvent(obj *unstructured.Unstructured) error {
581581
}
582582

583583
ambientMlflowObsSecretCopied := false
584+
mlflowK8sAuth := false
584585
mlflowTracingEnabled := os.Getenv("MLFLOW_TRACING_ENABLED") != "" && os.Getenv("MLFLOW_TRACING_ENABLED") != "0" && os.Getenv("MLFLOW_TRACING_ENABLED") != "false"
585586

586587
if mlflowTracingEnabled {
@@ -593,6 +594,9 @@ func handleAgenticSessionEvent(obj *unstructured.Unstructured) error {
593594
log.Printf("Warning: Failed to copy MLflow observability secret: %v. MLflow tracing will be disabled for this session.", err)
594595
} else {
595596
ambientMlflowObsSecretCopied = true
597+
if authVal, ok := mlflowSecret.Data["MLFLOW_TRACKING_AUTH"]; ok && string(authVal) == "kubernetes-namespaced" {
598+
mlflowK8sAuth = true
599+
}
596600
log.Printf("Successfully copied %s to %s", mlflowObsSecretName, sessionNamespace)
597601
}
598602
} else if !errors.IsNotFound(err) {
@@ -886,7 +890,7 @@ func handleAgenticSessionEvent(obj *unstructured.Unstructured) error {
886890
// Create the Pod directly (no Job wrapper for faster startup)
887891
runnerSATokenAutomount := false
888892
var runnerPodSAName string
889-
if ambientMlflowObsSecretCopied {
893+
if ambientMlflowObsSecretCopied && mlflowK8sAuth {
890894
// MLflow MLFLOW_TRACKING_AUTH=kubernetes-namespaced reads token + namespace from
891895
// /var/run/secrets/kubernetes.io/serviceaccount/ (requires automount + session SA).
892896
runnerSATokenAutomount = true
@@ -1176,16 +1180,6 @@ func handleAgenticSessionEvent(obj *unstructured.Unstructured) error {
11761180
},
11771181
},
11781182
},
1179-
corev1.EnvVar{
1180-
Name: "MLFLOW_TRACKING_AUTH",
1181-
ValueFrom: &corev1.EnvVarSource{
1182-
SecretKeyRef: &corev1.SecretKeySelector{
1183-
LocalObjectReference: corev1.LocalObjectReference{Name: mlflowObsSecretName},
1184-
Key: "MLFLOW_TRACKING_AUTH",
1185-
Optional: boolPtr(true),
1186-
},
1187-
},
1188-
},
11891183
corev1.EnvVar{
11901184
Name: "MLFLOW_WORKSPACE",
11911185
ValueFrom: &corev1.EnvVarSource{

0 commit comments

Comments
 (0)