mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-30 18:41:49 -07:00
Add CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_USE_RAMPING_VERSION (#9894)
## What changed?
Add `CONTINUE_AS_NEW_VERSIONING_BEHAVIOR_USE_RAMPING_VERSION` as a
`ContinueAsNewInitialVersioningBehavior` in `InheritedAutoUpgradeInfo`
and `VersioningInfo`, which if set, forces the first task of an
AutoUpgrade workflow to go to the Ramping Version of its task queue
instead of basing the Current/Ramping version selection on ramp
percentage and workflow id. If there is no Ramping Version at the time
of workflow dispatch, the workflow will use the Current Version.
This initial behavior comes from the continue-as-new command, and when
history sends workflow tasks to matching, is converted into an
internally defined `UseRampingVersionInitialTask bool` such that _only_
the first workflow task of an AutoUpgrade workflow will change its
Target Version selection. Retries of this workflow will start with the
same behavior, but child workflows and future continue-as-new workflows
initiated by this workflow will not inherit the initial behavior.
## Why?
To enable more fine grained control of upgrade-on-continue-as-new
upgrade stages before doing percentage based ramp. To use this, users
should set their promotion candidate version to the ramping version with
a ramp percentage of zero, and manually signal a certain cohort of
workflows to upgrade-on-continue-as-new with this option.
## How did you test it?
- [x] built
- [ ] 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]
> **Medium Risk**
> Changes workflow-task routing for AutoUpgrade executions by adding a
new directive flag that can bypass ramp-percentage hashing for the
initial task. Moderate risk because it affects matching/history version
selection and ContinueAsNew/retry inheritance semantics.
>
> **Overview**
> Adds a new `use_ramping_version` field to `TaskVersionDirective` and
threads it through history → matching so an AutoUpgrade workflow can
*force its initial workflow task* to route to the task queue’s ramping
deployment version (falling back to current when no ramping version
exists), bypassing the normal ramp-percentage/workflow-id hash.
>
> History now persists and evaluates the ContinueAsNew-requested initial
behavior via `MutableState.GetShouldUseRampingVersion()`, ensures it
applies only to the first workflow task, propagates it across retries,
and explicitly does **not** propagate it to child workflows or
subsequent ContinueAsNew hops. Updates tests (unit +
`versioning_3_test`) and bumps `go.temporal.io/api` to pick up the new
proto/enum support.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
923602f0c2. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
This commit is contained in:
committed by
GitHub
parent
76beb85a07
commit
ac3c439a1a
@@ -52,8 +52,19 @@ type TaskVersionDirective struct {
|
||||
// Counter copied from the workflow execution's WorkflowExecutionVersioningInfo
|
||||
// during enqueue time.
|
||||
RevisionNumber int64 `protobuf:"varint,6,opt,name=revision_number,json=revisionNumber,proto3" json:"revision_number,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
// If behavior is AutoUpgrade and use_ramping_version is true, then this task should use the
|
||||
// Ramping Version of its Task Queue regardless of workflow_id and ramp_percentage.
|
||||
// If there is no Ramping Version at the time of task dispatch, the Current Version will be used instead.
|
||||
//
|
||||
// If use_ramping_version is false, the Target Version is chosen with the default formula:
|
||||
//
|
||||
// if calcRampThreshold(workflow_id) <= ramp_percentage:
|
||||
// target=ramping_version
|
||||
// else:
|
||||
// target=current_version
|
||||
UseRampingVersion bool `protobuf:"varint,7,opt,name=use_ramping_version,json=useRampingVersion,proto3" json:"use_ramping_version,omitempty"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *TaskVersionDirective) Reset() {
|
||||
@@ -139,6 +150,13 @@ func (x *TaskVersionDirective) GetRevisionNumber() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *TaskVersionDirective) GetUseRampingVersion() bool {
|
||||
if x != nil {
|
||||
return x.UseRampingVersion
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type isTaskVersionDirective_BuildId interface {
|
||||
isTaskVersionDirective_BuildId()
|
||||
}
|
||||
@@ -931,7 +949,7 @@ var File_temporal_server_api_taskqueue_v1_message_proto protoreflect.FileDescrip
|
||||
|
||||
const file_temporal_server_api_taskqueue_v1_message_proto_rawDesc = "" +
|
||||
"\n" +
|
||||
".temporal/server/api/taskqueue/v1/message.proto\x12 temporal.server.api.taskqueue.v1\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a(temporal/api/deployment/v1/message.proto\x1a&temporal/api/enums/v1/task_queue.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a'temporal/api/taskqueue/v1/message.proto\x1a/temporal/server/api/deployment/v1/message.proto\x1a'temporal/server/api/enums/v1/task.proto\"\xbf\x03\n" +
|
||||
".temporal/server/api/taskqueue/v1/message.proto\x12 temporal.server.api.taskqueue.v1\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a(temporal/api/deployment/v1/message.proto\x1a&temporal/api/enums/v1/task_queue.proto\x1a$temporal/api/enums/v1/workflow.proto\x1a'temporal/api/taskqueue/v1/message.proto\x1a/temporal/server/api/deployment/v1/message.proto\x1a'temporal/server/api/enums/v1/task.proto\"\xef\x03\n" +
|
||||
"\x14TaskVersionDirective\x12J\n" +
|
||||
"\x14use_assignment_rules\x18\x01 \x01(\v2\x16.google.protobuf.EmptyH\x00R\x12useAssignmentRules\x12,\n" +
|
||||
"\x11assigned_build_id\x18\x02 \x01(\tH\x00R\x0fassignedBuildId\x12E\n" +
|
||||
@@ -940,7 +958,8 @@ const file_temporal_server_api_taskqueue_v1_message_proto_rawDesc = "" +
|
||||
"deployment\x18\x04 \x01(\v2&.temporal.api.deployment.v1.DeploymentR\n" +
|
||||
"deployment\x12i\n" +
|
||||
"\x12deployment_version\x18\x05 \x01(\v2:.temporal.server.api.deployment.v1.WorkerDeploymentVersionR\x11deploymentVersion\x12'\n" +
|
||||
"\x0frevision_number\x18\x06 \x01(\x03R\x0erevisionNumberB\n" +
|
||||
"\x0frevision_number\x18\x06 \x01(\x03R\x0erevisionNumber\x12.\n" +
|
||||
"\x13use_ramping_version\x18\a \x01(\bR\x11useRampingVersionB\n" +
|
||||
"\n" +
|
||||
"\bbuild_id\"A\n" +
|
||||
"\tFairLevel\x12\x1b\n" +
|
||||
|
||||
Reference in New Issue
Block a user