Skip to content

feat(runtime): support Image and Command in PodSet Container#3312

Open
Raakshass wants to merge 1 commit intokubeflow:masterfrom
Raakshass:feat/podset-container-image-command
Open

feat(runtime): support Image and Command in PodSet Container#3312
Raakshass wants to merge 1 commit intokubeflow:masterfrom
Raakshass:feat/podset-container-image-command

Conversation

@Raakshass
Copy link
Copy Markdown

What this PR does

Fixes #3177

Populates Image and Command fields in toPodSetContainer from ContainerApplyConfiguration, and adds an InitContainers sync loop in the JobSet Build() method to propagate Image, Command, Env, Ports, and VolumeMounts from PodSet.InitContainers back to the JobSet spec.

Root Cause

Two gaps prevented PodSet from being used for InitContainer customization:

  1. toPodSetContainer in runtime.go — Created Container structs but skipped Image and Command, only copying Name, Env, Ports, VolumeMounts. The Container struct already had Image and Command fields, but they were never populated from ContainerApplyConfiguration.

  2. Build() in jobset.go — Synced Image, Command, Env, Ports, and VolumeMounts from PodSet.Containers back to the JobSet spec, but had no equivalent sync loop for PodSet.InitContainers.

Changes

File Change
pkg/runtime/runtime.go Populate Image and Command in toPodSetContainer from ContainerApplyConfiguration
pkg/runtime/framework/plugins/jobset/jobset.go Add InitContainers sync loop in Build() mirroring the existing Containers sync
pkg/runtime/runtime_test.go Update TestNewInfo to set Image/Command on an InitContainer input and assert roundtrip

Context

This unblocks the Flux Framework integration (#3064) from using PodSet for InitContainer customization, as discussed in:

Testing

  • All ./pkg/runtime/... unit tests pass (runtime, framework/core, framework/plugins/jobset, indexer)
  • TestNewInfo updated to verify InitContainer Image/Command propagation

Contributor Checklist

  • DCO sign-off included (Signed-off-by: Siddhant Jain <siddhantjainofficial26@gmail.com>)
  • Unit tests updated and passing
  • No unrelated files in diff
  • PR title follows Conventional Commits specification
  • Changes match master's existing patterns (InitContainers sync mirrors Containers sync)

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>
Copilot AI review requested due to automatic review settings March 11, 2026 20:04
@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign electronic-waste for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions
Copy link
Copy Markdown

🎉 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:

  • If you haven't already, please check out our Contributing Guide for repo-specific guidelines and the Kubeflow Contributor Guide for general community standards.
  • Our team will review your PR soon! cc @kubeflow/kubeflow-trainer-team

Join the community:

Feel free to ask questions in the comments if you need any help or clarification!
Thanks again for contributing to Kubeflow! 🙏

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.Image and runtime.Container.Command when building PodSet containers from PodSpec apply configs.
  • Propagate init container image/command (plus env/ports/volumeMounts upserts) from PodSet back into the JobSet apply configuration during JobSet.Build.
  • Update runtime unit test expectations to include init container image and command.

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.

Comment on lines +296 to +298
if container.Image != "" {
jobSetSpec.ReplicatedJobs[psIdx].Template.Spec.Template.Spec.InitContainers[containerIdx].Image = &container.Image
}
Copy link

Copilot AI Mar 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: PodSet Container to support Image and Command

2 participants