acoustic-carpenter-78188
06/17/2026, 10:50 PMDefaultAffinity), because MergeOverlayPodSpecOntoBase uses `mergo.WithAppendSlice`: the custom pod's NodeSelectorTerms are appended as new OR'd terms, and Kubernetes ORs terms. So a required requirement that the base carried only sits on the base term, and a pod satisfying just the appended custom term bypasses it.
Originally reported for Ray (interruptible=False worker landing on spot). Investigation found the same class affects DefaultAffinity and the Spark driver/executor path.
Fix
Add flytek8s.ApplyPlatformSchedulingConstraints(interruptible, podSpec) (pod_helper.go): re-applies, idempotently, the configured DefaultAffinity requirements and the (Non)InterruptibleNodeSelectorRequirement to every node selector term (including appended ones), plus the interruptible node selector/tolerations. Call it after each custom pod-spec merge:
• Ray buildHeadPodTemplate / buildWorkerPodTemplate (head + worker follow the task flag).
• Spark createDriverSpec (forced non-interruptible) / createExecutorSpec (follows the task flag).
AddRequiredNodeSelectorRequirements and addTolerationInPodSpec skip entries already present, so re-applying to an unmerged base pod is a no-op — the no-custom-pod paths are unchanged.
Dask is unaffected: it merges no custom pod overlay (createWorkerSpec deep-copies the base) and its proto exposes no per-worker pod-spec field, so there is no dilution vector. Existing TestBuildResourceDaskInterruptible already covers it.
Tests (each reproduces the bug, then passes with the fix)
• TestBuildResourceRayInterruptible + TestBuildResourceRayInterruptibleCustomAffinity (interruptible, incl. OR-hole).
• TestBuildResourceRayDefaultAffinityDilution (DefaultAffinity OR-hole).
• TestBuildResourceSparkExecutorAffinityDilution (Spark executor OR-hole).
go test ./go/tasks/plugins/k8s/ray/... ./go/tasks/plugins/k8s/spark/... ./go/tasks/plugins/k8s/dask/... ./go/tasks/pluginmachinery/flytek8s/... passes; go vet clean.
Out of scope (intentional, not bugs)
Scalar overrides (SchedulerName / PriorityClassName / RuntimeClassName) and NodeSelector map-key collisions only change when the user's own pod template sets them — a deliberate override, not silent loss of a platform constraint.
🤖 Generated with Claude Code
flyteorg/flyteacoustic-carpenter-78188
06/18/2026, 12:07 AM