fix(workload): resolve Kubernetes v0.15+ condition sorting issue#1149
Merged
Conversation
840f1be to
53e163c
Compare
- Replace brittle `[-1]` array indices when querying Kubernetes `status.conditions`. - Update `_parse_workload_item` to dynamically determine the latest condition by comparing `lastTransitionTime` (unconditionally). - Refactor `kubectl wait` to use native order-agnostic flag `--for=condition=Finished`. - Change `kubectl get jobset` to parse full JSON via Python instead of fragile JSONPath. - Update tests to match new command structures.
- Created to encapsulate timestamp-based sorting. - Extracted JobSet JSON parsing into utilizing the new helper function. - Cleaned up and . - Added new test coverage for success and failure cases. - Improved mock assertions.
- Introduced `_KubernetesStatus` and `_KubernetesCondition` minimal dataclasses. - Added `_parse_kubernetes_status` to encapsulate raw JSON to dataclass mapping, ensuring fields strictly remain `None` when empty/missing. - Refactored `_get_latest_condition`, `_parse_workload_item`, and `_get_jobset_status` to strictly consume these dataclasses instead of iterating through dicts directly.
SikaGrr
approved these changes
Mar 20, 2026
SikaGrr
left a comment
Collaborator
There was a problem hiding this comment.
Alphabetically sorted, ouch!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Previously, XPK logic for fetching workload status relied on grabbing the last item in the
.status.conditionsarray (e.g.,conditions[-1]). However, starting with Kueue v0.15+ (and due to Kubernetes Server-Side Apply map sorting behavior), conditions are now sorted alphabetically by theirtypefield rather than chronologically. As a result, critical statuses likeFinishedmight appear beforeQuotaReservedin the JSON array, causingxpk workload listand wait logic to report stale or incorrect status types.Issue
b/494200808
Testing