Skip to content

fix: inject Katib labels early to support PodDefaults for trial pods#2620

Open
Priyanshu-u07 wants to merge 1 commit intokubeflow:masterfrom
Priyanshu-u07:katib-poddefault-trial
Open

fix: inject Katib labels early to support PodDefaults for trial pods#2620
Priyanshu-u07 wants to merge 1 commit intokubeflow:masterfrom
Priyanshu-u07:katib-poddefault-trial

Conversation

@Priyanshu-u07
Copy link

When a trial pod is created, Katib labels like katib.kubeflow.org/trial are added too late . They get added by a webhook that runs after the PodDefaults webhook has already finished checking. Because of this timing issue, PodDefaults that depend on Katib labels are never applied to trial pods.

This PR fixes it by adding the labels directly into the pod template before the pod is created, so PodDefaults can see them in time.

Changes:

  • Added InjectLabelsToPodTemplate utility in pkg/controller.v1beta1/util/unstructured.go that injects labels into Pod templates across workload types (Job, CronJob, Training Operator replicaSpecs)
  • Updated generator.go to inject experiment labels into the trial template early
  • Updated trial_controller.go to inject trial name labels into the workload before creation
  • Added unit tests covering all supported workload types, including edge case where no initial labels exist

Fixes #2548

Signed-off-by: Priyanshu-u07 <connect.priyanshu8271@gmail.com>
@github-actions
Copy link

🎉 Welcome to the Kubeflow Katib repo! 🎉

Thanks for opening your first PR! We're excited to have you onboard 🚀

Next steps:

Feel free to ask questions in the comments. Thanks again for contributing! 🙏

@google-oss-prow
Copy link

[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 andreyvelich 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

@Priyanshu-u07
Copy link
Author

@andreyvelich Could you please take a look when you get a chance?
Thanks!

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.

PodDefaults over trial pods not being applied accordingly

1 participant