-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add support for standalone activity termination #8665
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
8710d0b to
de5e4f2
Compare
|
cursor review |
chasm/lib/activity/statemachine.go
Outdated
| } | ||
|
|
||
| return store.RecordCompleted(ctx, func(ctx chasm.MutableContext) error { | ||
| attempt, err := a.Attempt.Get(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why update the last attempt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we're updating the last worker identity from the termination req. If the identity should not be updated on termination, lmk.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, it's not safe to assume that the identity in the termination request is the identity of a worker processing the current attempt. Most likely it'll be a separate client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, removed.
What's the purpose of the Identity field in TerminateActivityExecutionRequest? For our purposes should we ignore it?
chasm/lib/activity/activity.go
Outdated
| return heartbeat, nil | ||
| } | ||
|
|
||
| func (a *Activity) handleTerminated(ctx chasm.MutableContext, req *activitypb.TerminateActivityExecutionRequest) ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should dedupe based on the request ID. I forgot that detail in my initial review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this requires API change, I'll do this as a separate PR.
bergundy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with comments.
| } | ||
|
|
||
| failure := &failurepb.Failure{ | ||
| Message: req.GetFrontendRequest().GetReason(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put a TODO to revisit this. If the reason isn't provided we'll have an empty message, which isn't great.
I'm also wondering if we want to prefix the reason with:
"Activity terminated: " + req.GetFrontendRequest().GetReason().
Best bring this up in the crew channel on slack. Same for cancelation reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added TODO, will ping crew
## What changed? Added standalone activity termination handling. ## Why? Needed to support standalone activities full operation. ## How did you test it? - [X] built - [X] run locally and tested manually - [X] covered by existing tests - [X] added new unit test(s) - [X] added new functional test(s) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Adds termination support for standalone activities across API, frontend/handler, state machine, and tests. > > - **API/Proto**: > - Add `TerminateActivityExecution` RPC: request/response messages in `proto/v1/request_response.proto` and service in `proto/v1/service.proto`. > - Regenerate clients/servers: `activitypb` request/response, service, layered client, and gRPC stubs. > - **Frontend**: > - Implement `TerminateActivityExecution` in `frontend.go` to resolve namespace and forward to activity service. > - **Backend/Handler**: > - Add handler `TerminateActivityExecution` to update component via `(*Activity).handleTerminated`. > - Add `Activity.handleTerminated` to apply termination transition. > - **State Machine**: > - Enhance `TransitionTerminated` to finalize execution, set `LastWorkerIdentity`, and record `TerminatedFailureInfo` in outcome. > - **Tests**: > - Add unit test `TestTransitionTerminated`. > - Add functional tests for terminating an activity and preventing termination after completion. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit de5e4f2. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Dan Davison <dan.davison@temporal.io>
What changed?
Added standalone activity termination handling.
Why?
Needed to support standalone activities full operation.
How did you test it?
Note
Adds termination support for standalone activities across API, frontend/handler, state machine, and tests.
TerminateActivityExecutionRPC: request/response messages inproto/v1/request_response.protoand service inproto/v1/service.proto.activitypbrequest/response, service, layered client, and gRPC stubs.TerminateActivityExecutioninfrontend.goto resolve namespace and forward to activity service.TerminateActivityExecutionto update component via(*Activity).handleTerminated.Activity.handleTerminatedto apply termination transition.TransitionTerminatedto finalize execution, setLastWorkerIdentity, and recordTerminatedFailureInfoin outcome.TestTransitionTerminated.Written by Cursor Bugbot for commit de5e4f2. This will update automatically on new commits. Configure here.