Skip to content

Commit a1bcee5

Browse files
committed
Fix kfp-kubernetes-library-tests and backend driver Optional field handling
- Regenerate Python protobuf bindings to include the optional field for SecretAsEnv and ConfigMapAsEnv - Update test_volume.py to expect optional: False in secretAsEnv - Fix backend driver to properly handle Optional field for all cases: * Not specified: Optional = nil → defaults to false in YAML (backward compatible) * Explicitly false: Optional = &false → optional: false in YAML * Explicitly true: Optional = &true → optional: true in YAML - All 110 kfp-kubernetes-library-tests pass - All backend driver tests pass - Sample pipeline compilation tests pass with correct optional field handling - Should fix KFP Samples test failures related to pod-spec-patch - Fixes PR #12216 test failures Signed-off-by: ddalvi <[email protected]>
1 parent 10cdb55 commit a1bcee5

File tree

3 files changed

+68
-53
lines changed

3 files changed

+68
-53
lines changed

backend/src/v2/driver/k8s.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,19 @@ func extendPodSpecPatch(
273273
// Get secret env information
274274
for _, secretAsEnv := range kubernetesExecutorConfig.GetSecretAsEnv() {
275275
for _, keyToEnv := range secretAsEnv.GetKeyToEnv() {
276+
secretKeySelector := &k8score.SecretKeySelector{
277+
Key: keyToEnv.GetSecretKey(),
278+
}
279+
280+
// Set Optional field when explicitly provided (true or false), leave nil when not specified
281+
if secretAsEnv.Optional != nil {
282+
secretKeySelector.Optional = secretAsEnv.Optional
283+
}
284+
276285
secretEnvVar := k8score.EnvVar{
277286
Name: keyToEnv.GetEnvVar(),
278287
ValueFrom: &k8score.EnvVarSource{
279-
SecretKeyRef: &k8score.SecretKeySelector{
280-
Key: keyToEnv.GetSecretKey(),
281-
},
288+
SecretKeyRef: secretKeySelector,
282289
},
283290
}
284291

@@ -341,12 +348,19 @@ func extendPodSpecPatch(
341348
// Get config map env information
342349
for _, configMapAsEnv := range kubernetesExecutorConfig.GetConfigMapAsEnv() {
343350
for _, keyToEnv := range configMapAsEnv.GetKeyToEnv() {
351+
configMapKeySelector := &k8score.ConfigMapKeySelector{
352+
Key: keyToEnv.GetConfigMapKey(),
353+
}
354+
355+
// Set Optional field when explicitly provided (true or false), leave nil when not specified
356+
if configMapAsEnv.Optional != nil {
357+
configMapKeySelector.Optional = configMapAsEnv.Optional
358+
}
359+
344360
configMapEnvVar := k8score.EnvVar{
345361
Name: keyToEnv.GetEnvVar(),
346362
ValueFrom: &k8score.EnvVarSource{
347-
ConfigMapKeyRef: &k8score.ConfigMapKeySelector{
348-
Key: keyToEnv.GetConfigMapKey(),
349-
},
363+
ConfigMapKeyRef: configMapKeySelector,
350364
},
351365
}
352366

0 commit comments

Comments
 (0)