Repository navigation
Conversation
|
Please translate all the PR title, description, and comments into English for review. |
* `TestJSONRPC_DeletePushConfigResponse` ignores the ErrorInfo `timestamp` when comparing responses, as the error conversion tests in `internal/jsonrpc`, `internal/rest` and `internal/grpcutil` already do. The expected error is built when the test cases are declared, and `jsonrpc.ToJSONRPCError` stamps the current time with second precision, so the test failed whenever the handler ran in the next second. The test failed this way today on #505, #531 and #536. Sleeping until the next second before calling the handler fails the old test in every run and passes with this change.
| return newRemoteSubscription(queue, m.taskStore, taskID), nil | ||
| } | ||
|
|
||
| // Cancel waits for the cancellation result without treating an old input-required snapshot as a refusal. |
There was a problem hiding this comment.
let's remove, it describes the change, not the method
| // The old nonterminal snapshot provides an event watermark, not a cancellation result. | ||
| // Send and Subscribe retain remoteSubscription behavior. Cancel consumes subsequent worker events. |
There was a problem hiding this comment.
same here, let's drop. the comment on the watermark below is the useful one
| snapshot, snapshotErr := m.taskStore.Get(ctx, req.ID) | ||
| if snapshotErr != nil && !errors.Is(snapshotErr, a2a.ErrTaskNotFound) { | ||
| subscriptionErr = fmt.Errorf("task snapshot loading failed: %w", snapshotErr) | ||
| } else { | ||
| // Use the version before enqueueing so a fast worker refusal is not hidden by the later snapshot. | ||
| snapshotVersion := storedTask.Version | ||
| if snapshot != nil { | ||
| if snapshot.Task.Status.State.Terminal() { | ||
| return convertToCancelationResult(ctx, snapshot.Task, nil) | ||
| } | ||
| } | ||
| if a2aevent.IsFinal(event) { | ||
| if result, ok := event.(*a2a.Task); ok { | ||
| return convertToCancelationResult(ctx, result, nil) | ||
| for { | ||
| msg, readErr := queue.Read(ctx) | ||
| if readErr != nil { | ||
| subscriptionErr = readErr | ||
| break | ||
| } | ||
| if msg.TaskVersion != taskstore.TaskVersionMissing && !msg.TaskVersion.After(snapshotVersion) { | ||
| continue | ||
| } | ||
| // A subsequent INPUT_REQUIRED event still indicates refusal and must remain observable. | ||
| if a2aevent.IsFinal(msg.Event) { | ||
| if result, ok := msg.Event.(*a2a.Task); ok { | ||
| return convertToCancelationResult(ctx, result, nil) | ||
| } | ||
| break | ||
| } | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
this duplicates remoteSubscription.Events. let's add options to remoteSubscription instead (don't yield a nonterminal snapshot, use a given version as the watermark) or at least move the loop to a helper and return early instead of nesting under else
| if snapshot != nil { | ||
| if snapshot.Task.Status.State.Terminal() { | ||
| return convertToCancelationResult(ctx, snapshot.Task, nil) | ||
| } | ||
| } |
There was a problem hiding this comment.
nit:
| if snapshot != nil { | |
| if snapshot.Task.Status.State.Terminal() { | |
| return convertToCancelationResult(ctx, snapshot.Task, nil) | |
| } | |
| } | |
| if snapshot != nil && snapshot.Task.Status.State.Terminal() { | |
| return convertToCancelationResult(ctx, snapshot.Task, nil) | |
| } |
| } | ||
|
|
||
| // newCancelSnapshotRuntime uses the real handler, in-memory store, and executor, with channels controlling worker ordering. | ||
| func newCancelSnapshotRuntime(t *testing.T, initial, final a2a.TaskState, fullTask, fast, replayOld bool) *cancelSnapshotRuntime { |
There was a problem hiding this comment.
I'd rather add cases to TestClusterFrontend_Cancel in distributed_manager_test.go, it already sequences store results. a test queue returning given events and versions should cover the rest. three positional bools are also hard to read at call sites
| // Cancel uses the first read for admission and the second for the initial snapshot. The worker does not inherit the test marker. | ||
| if ctx.Value(cancelSnapshotContextKey{}) == true && reads.Add(1) == 2 { |
There was a problem hiding this comment.
this breaks as soon as Cancel adds or removes a Get call
| writes *atomic.Int32 | ||
| } | ||
|
|
||
| // newCancelSnapshotRuntime uses the real handler, in-memory store, and executor, with channels controlling worker ordering. |
There was a problem hiding this comment.
nit: no need to document test helpers and test funcs, here and in other places
| t.Parallel() | ||
| ctx, cancel := context.WithTimeout(t.Context(), 5*time.Second) | ||
| defer cancel() | ||
| runtime := newCancelSnapshotRuntime(t, state, a2a.TaskStateCanceled, false, false, false) |
There was a problem hiding this comment.
nit: runtime -> rt, shadows the stdlib package name
|
Wanted to ship this in 2.9.0, so fixed in #560 |
#560) Supersedes #505 with the review comments applied. Thanks @ickeep for the original fix. - Added `newRemoteCancelSubscription`, used by `distributedManager.Cancel`. It emits the stored snapshot only when it is terminal, because `IsFinal` treats `INPUT_REQUIRED` as final and an input-required snapshot was returned as a cancelation refusal before the worker could persist `CANCELED`. - The cancel subscription skips events not newer than the task version loaded before the cancel request is written, so a refusal persisted by a fast worker is still observed. - `Execute` and `Resubscribe` subscriptions still emit the snapshot first. Co-authored-by: ickeep <[email protected]>
In cluster mode, CancelTask reads an old remoteSubscription snapshot before observing the cancellation worker's result. An INPUT_REQUIRED snapshot is treated as a final event for that Send execution, so cancellation immediately returns ErrTaskNotCancelable even though the worker can subsequently persist CANCELED.
This change only adjusts distributedManager.Cancel. It skips an old nonterminal snapshot, filters stale events using the task version read before enqueueing, and waits for the cancellation result. Using the pre-enqueue watermark preserves genuine refusal events from a fast worker. Subsequent INPUT_REQUIRED Task or Status events still return the existing refusal error. Send and Subscribe retain snapshot-first behavior. No polling, retries, service calls, API changes, or storage changes are introduced.
Validation on the implementation commit
2692308d0926f05fa8e7892e2dacb099848200feand passes with the fix.go test -race -mod=readonly -count=1 -shuffle=on ./...,go build -mod=readonly ./..., andgo vet ./...pass.The independent empty-slice fix is #504. This PR does not depend on it. Existing taskstore fallback error classification is retained, including its existing deadline-sentinel mapping limits.