[Feature] Propagate labels from RayJob to submitter Kubernetes job #3637
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
This pull request enhances the label management for RayJob submitter pods and introduces tests to ensure correctness. The main changes include propagating labels from the RayJob to the submitter pod, adding a utility function for label merging, and creating unit tests for these functionalities.
Enhancements to Label Management:
RayJob
are now copied to the submitter pod template, ensuring consistent labeling across resources. (ray-operator/controllers/ray/rayjob_controller.go
, ray-operator/controllers/ray/rayjob_controller.goR569-R574)mergeLabels
utility function to merge multiple label maps, with precedence given to the rightmost map. This ensures systematic handling of labels. (ray-operator/controllers/ray/rayjob_controller.go
, ray-operator/controllers/ray/rayjob_controller.goR933-R943)mergeLabels
function, ensuring both system and custom labels are applied consistently. (ray-operator/controllers/ray/rayjob_controller.go
, ray-operator/controllers/ray/rayjob_controller.goR585-R605)Unit Tests:
RayJob
are correctly propagated to both the Kubernetes job and its pod template. (ray-operator/controllers/ray/rayjob_controller_unit_test.go
, ray-operator/controllers/ray/rayjob_controller_unit_test.goR627-R766)mergeLabels
Function: Added comprehensive test cases to validate the correctness of themergeLabels
utility function under various scenarios. (ray-operator/controllers/ray/rayjob_controller_unit_test.go
, ray-operator/controllers/ray/rayjob_controller_unit_test.goR627-R766)Related issue number
Closes #3638
Checks