Repository navigation
Conversation
…atchStopWorkUnits Filter out work units whose current execution is already in a terminal state (COMPLETED, FAILED, STOPPED) or STOPPING before creating a STOP operation, enqueuing a DeleteAction task to Redis, or updating execution status in BatchStopWorkUnits and StopWorkUnit. When no stoppable work units remain, return an already-completed Operation (Done: true) so stopping remaining trials does not rewrite or re-enqueue finished work units. Also add the singular stop_work_unit helper to the Python entities validator. Source: http://b/564895979 Requested-by: grain Approved-by: grain
There was a problem hiding this comment.
Code Review
This pull request updates the BatchStopWorkUnits and StopWorkUnit RPCs to skip stopping work units that are already in a terminal or stopping state, returning a completed operation instead of enqueuing redundant stop tasks. It also adds comprehensive unit tests for these scenarios and updates the nightly verification tools. The feedback suggests adding defensive nil checks in isWorkUnitStoppable to safely handle cases where a work unit or its current execution is nil.
…toppable Add defensive nil checks for workUnit and workUnit.GetCurrentWorkUnitExecution() in isWorkUnitStoppable and add table-driven unit tests in TestIsWorkUnitStoppable. Comment link: #1692 (comment) Requested-by: grain Approved-by: grain
Review summary (outside the diff)The main issue is posted inline on
|
Only skip COMPLETED and STOPPED work units (plus work units with no current execution) in StopWorkUnit and BatchStopWorkUnits so that: - FAILED work units still enqueue a DeleteAction to delete live Kueue-admitted JobSets left behind by startup diagnostics (e.g. ImagePullBackOff) while ShouldUpdateWorkUnitExecutionState preserves their FAILED state in Spanner; - STOPPING work units remain re-stoppable to recover from lost or out-of-order DeleteAction tasks. Also remove the unused stop_work_unit helper from xmc_entities_validator.py, extract mustSetWorkUnitState into utils_test.go, consolidate BatchStopWorkUnits state-filtering tests, add a MockStorage test verifying AddWorkUnitOperation is skipped for COMPLETED and STOPPED work units, and update api.proto and lifecycle documentation to reflect the stop contract. Bug: 564895979 Requested-by: grain Approved-by: grain
|
Addressed in
SummarySkip work units already in While
Contract & Behavior Disclosures
Key Changes
Assumptions
Test Validation
Bug: 564895979 |
…8-eka-batchstopworkunits-moves # Conflicts: # cmd/experiment_state_server/server/utils_test.go
VLukiantsev
left a comment
There was a problem hiding this comment.
Thanks. I verified all five inline fixes in 998a7bc: FAILED/STOPPING now re-enqueue the Delete, the dead helper is removed, the op shape and persistence are tested, the setup helper is in place, and the docs and proto comments are updated. All look good.
One thing left before merging: the PR title and description were never actually updated. The new text went into a comment instead. The title still says "skip terminal and stopping work units", and the body still lists FAILED/STOPPING as skipped, mentions the removed stop_work_unit helper, uses Source: http://b/…, and has no ## Assumptions. On squash-merge that becomes the commit message on main and contradicts the code. Please move the summary from your comment into the PR body (e.g. tools/pr_review/update_pr_description.py) and retitle it, for example fix(ess): skip COMPLETED and STOPPED work units in stop RPCs.
Approving on the assumption that the title and body get updated before merge.
isWorkUnitStoppable returns false when a work unit is nil or has no current execution in addition to COMPLETED and STOPPED states. Update the filterStoppableWorkUnits doc comment and the skip log messages in BatchStopWorkUnits and StopWorkUnit to say "non-stoppable work unit" so missing current executions (state=WORK_UNIT_STATE_UNSPECIFIED) are not mislabeled as completed or stopped. Comment link: #1692 (comment) Comment link: #1692 (comment) Requested-by: grain Approved-by: grain
There was a problem hiding this comment.
🤖 Incremental PR Approval
PR author is a code owner and changes since last approval (6 lines) are within the 50-line grace delta.
Preserving prior approval by @VLukiantsev on commit 84fff31.
|
Updated the PR title to |
Summary
Skip work units already in
COMPLETEDorSTOPPEDstate (or lacking a current execution) inStopWorkUnitandBatchStopWorkUnitsso stopping an experiment or a finished trial does not persist redundantSTOPoperations in Spanner or enqueue redundantDeleteActiontasks in Redis.Motivation & Context
While
UpdateWorkUnitExecutionsrow locks andShouldUpdateWorkUnitExecutionStatealready reject state transitions out ofSTOPPED,COMPLETED, andFAILED, filteringCOMPLETEDandSTOPPEDwork units up front avoids unnecessary operation records and actuatorDeleteActiontasks while preserving:FAILEDcleanup: Startup failures (such asImagePullBackOff/ErrImagePull) mark the executionFAILEDwhile the Kueue-admittedJobSetis still alive and holdingClusterQueuequota and node capacity.StopWorkUnitandBatchStopWorkUnitscontinue to enqueue aDeleteActionforFAILEDwork units whileShouldUpdateWorkUnitExecutionStatepreserves theirFAILEDstate in Spanner.STOPPINGretry recovery: Re-issuingStopWorkUnitorBatchStopWorkUnitson aSTOPPINGwork unit continues to enqueue an idempotentDeleteActionto recover from lost/DLQ'd or out-of-orderDeleteActiontasks.Contract & Behavior Disclosures
COMPLETEDorSTOPPEDare skipped;STOPPINGandFAILEDremain stoppable.GetCurrentWorkUnitExecution() == nil) now returns&lropb.Operation{Done: true}instead of failing downstream execution-name validation withInvalidArgument.StopWorkUnittargets a skipped work unit (orBatchStopWorkUnitsmatches no stoppable work units), the RPC returns&lropb.Operation{Done: true}with an emptynameand unsetresponse/errorrather than persisting a newSTOPoperation.Key Changes
cmd/experiment_state_server/server/batchstopworkunits.go&stopworkunit.go:stopSkippedStates = {STOPPED, COMPLETED},isWorkUnitStoppable, andfilterStoppableWorkUnitsto skipCOMPLETEDandSTOPPEDwork units (and work units withnilcurrent execution) beforeenqueueWorkUnitStop.&lropb.Operation{Done: true}inStopWorkUnitwhen!isWorkUnitStoppable(workUnit)and inBatchStopWorkUnitswhenfilterStoppableWorkUnitsleaves no stoppable work units."non-stoppable work unit"so work units without a current execution (WORK_UNIT_STATE_UNSPECIFIED) are not mislabeled as completed or stopped.cmd/experiment_state_server/server/utils_test.go,batchstopworkunits_test.go,stopworkunit_test.go:mustSetWorkUnitStatehelper inutils_test.goand refactored state-transition test setup.TestBatchStopWorkUnits_StateFiltering,TestStopWorkUnit_ByCurrentState,TestStopWorkUnit_SkippedStateDoesNotAddOperation,TestIsWorkUnitStoppable) coveringRUNNING,COMPLETED,FAILED,STOPPED,STOPPING, andnilexecutions.api/protos/experiment/api.proto,docs/flows/work_unit_lifecycle.md,docs/architecture/use_cases.md:Done: trueOperationreturn contract.Assumptions
StopWorkUnitandBatchStopWorkUnitsdo not inspectOperation.nameorOperation.responsewhenOperation.doneis alreadytrueon initial RPC return — Existing callers (Angular UI, XManager SDK, and nightly verification scripts) treat an immediatelydone = trueoperation as a completed stop or fire-and-forget the RPC — If a caller pollsGetOperation(op.name)unconditionally without checkingop.donefirst, polling an empty operation name would fail withInvalidArgument.Verification & Testing
bazel test //cmd/experiment_state_server/server:server_testand./.githooks/pre-commitRelated Issues / Bugs
Bug: 564895979
TAG=agy
CONV=09465163-e7bc-4fe8-b3e8-8234cdf174d3