feat(runtime): support Image and Command in PodSet Container#3312
feat(runtime): support Image and Command in PodSet Container#3312Raakshass wants to merge 1 commit intokubeflow:masterfrom
Conversation
Populate Image and Command fields in toPodSetContainer from ContainerApplyConfiguration. Add InitContainers sync loop in JobSet Build() to propagate Image, Command, Env, Ports, and VolumeMounts from PodSet InitContainers back to the JobSet spec. Update tests to verify Image/Command roundtrip for InitContainers. Closes kubeflow#3177 Signed-off-by: Siddhant Jain <siddhantjainofficial26@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
🎉 Welcome to the Kubeflow Trainer! 🎉 Thanks for opening your first PR! We're happy to have you as part of our community 🚀 Here's what happens next:
Join the community:
Feel free to ask questions in the comments if you need any help or clarification! |
There was a problem hiding this comment.
Pull request overview
This PR extends the runtime PodSet container extraction and JobSet template mutation logic so init container image and command are preserved and propagated into the JobSet apply spec.
Changes:
- Populate
runtime.Container.Imageandruntime.Container.Commandwhen buildingPodSetcontainers fromPodSpecapply configs. - Propagate init container
image/command(plus env/ports/volumeMounts upserts) fromPodSetback into the JobSet apply configuration duringJobSet.Build. - Update
runtimeunit test expectations to include init containerimageandcommand.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| pkg/runtime/runtime.go | Adds Image and Command mapping when converting container apply configs into runtime.Container. |
| pkg/runtime/runtime_test.go | Updates TestNewInfo expectations to assert init container Image/Command are captured. |
| pkg/runtime/framework/plugins/jobset/jobset.go | Extends JobSet build-time template sync to include init container command/image and related fields. |
| if container.Image != "" { | ||
| jobSetSpec.ReplicatedJobs[psIdx].Template.Spec.Template.Spec.InitContainers[containerIdx].Image = &container.Image | ||
| } |
There was a problem hiding this comment.
Setting Image via &container.Image takes the address of the range loop variable field, so multiple init containers can end up sharing the same pointer value (often the last iteration’s image); use a per-iteration copy (e.g., img := container.Image) or ptr.To(container.Image) when assigning the *string image field (and consider fixing the same pattern in the main containers loop above).
What this PR does
Fixes #3177
Populates
ImageandCommandfields in toPodSetContainer fromContainerApplyConfiguration, and adds anInitContainerssync loop in the JobSet Build() method to propagateImage,Command,Env,Ports, andVolumeMountsfromPodSet.InitContainersback to the JobSet spec.Root Cause
Two gaps prevented PodSet from being used for InitContainer customization:
toPodSetContainer in runtime.go — Created Container structs but skipped
ImageandCommand, only copying Name,Env,Ports,VolumeMounts. The Container struct already hadImageandCommandfields, but they were never populated fromContainerApplyConfiguration.Build() in jobset.go — Synced
Image,Command,Env,Ports, andVolumeMountsfromPodSet.Containersback to the JobSet spec, but had no equivalent sync loop forPodSet.InitContainers.Changes
ImageandCommandin toPodSetContainer fromContainerApplyConfigurationInitContainerssync loop in Build() mirroring the existingContainerssyncImage/Commandon an InitContainer input and assert roundtripContext
This unblocks the Flux Framework integration (#3064) from using PodSet for InitContainer customization, as discussed in:
Testing
./pkg/runtime/...unit tests pass (runtime,framework/core,framework/plugins/jobset,indexer)Image/CommandpropagationContributor Checklist
Signed-off-by: Siddhant Jain <siddhantjainofficial26@gmail.com>)