Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions service/worker/workerdeployment/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,8 @@ func (d *WorkflowRunner) validateStateBeforeAcceptingRampingUpdate(args *deploym
return temporal.NewApplicationError("conflict token mismatch", errFailedPrecondition)
}
//nolint:staticcheck // SA1019: worker versioning v0.31
if args.Version == d.State.GetRoutingConfig().GetCurrentVersion() {
if args.Version == d.State.GetRoutingConfig().GetCurrentVersion() &&
!(args.Version == worker_versioning.UnversionedVersionId && args.Percentage == 0) {
d.logger.Info("version can't be set to ramping since it is already current")
return temporal.NewApplicationError(fmt.Sprintf("requested ramping version %s is already current", args.Version), errFailedPrecondition)
}
Expand Down Expand Up @@ -908,14 +909,17 @@ func (d *WorkflowRunner) syncVersion(ctx workflow.Context, targetVersion string,
func (d *WorkflowRunner) syncUnversionedRamp(ctx workflow.Context, versionUpdateArgs *deploymentspb.SyncVersionStateUpdateArgs) error {
activityCtx := workflow.WithActivityOptions(ctx, defaultActivityOptions)

// DescribeVersion activity to get all the task queues in the current version
// DescribeVersion activity to get all the task queues in the current version, or the ramping version if current is nil
version := d.State.RoutingConfig.CurrentVersion //nolint:staticcheck // SA1019: worker versioning v0.31
if version == worker_versioning.UnversionedVersionId {
version = d.State.RoutingConfig.RampingVersion //nolint:staticcheck // SA1019: worker versioning v0.31
}
var res deploymentspb.DescribeVersionFromWorkerDeploymentActivityResult
err := workflow.ExecuteActivity(
activityCtx,
d.a.DescribeVersionFromWorkerDeployment,
&deploymentspb.DescribeVersionFromWorkerDeploymentActivityArgs{
Version: d.State.RoutingConfig.CurrentVersion, //nolint:staticcheck // SA1019: worker versioning v0.31

Version: version,
}).Get(ctx, &res)
if err != nil {
return err
Expand Down
21 changes: 19 additions & 2 deletions tests/worker_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,23 @@ func (s *WorkerDeploymentSuite) TestSetWorkerDeploymentRampingVersion_Invalid_Se
})
}

func (s *WorkerDeploymentSuite) TestSetWorkerDeploymentRampingVersion_Valid_SetNilCurrent_To_Ramping() {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()

tv := testvars.New(s).WithBuildIDNumber(1)
s.startVersionWorkflow(ctx, tv)

s.setAndVerifyRampingVersion(ctx, tv, false, 5, false, "", &workflowservice.SetWorkerDeploymentRampingVersionResponse{})

// should be able to unset ramping version while current version is nil with no error
s.setAndVerifyRampingVersion(ctx, tv, true, 0, true, "", &workflowservice.SetWorkerDeploymentRampingVersionResponse{
PreviousVersion: tv.DeploymentVersionString(), //nolint:staticcheck // SA1019: worker versioning v0.31
PreviousDeploymentVersion: tv.ExternalDeploymentVersion(),
PreviousPercentage: 5,
})
}

func (s *WorkerDeploymentSuite) TestSetWorkerDeploymentRampingVersion_ModifyExistingRampVersionPercentage() {
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
Expand Down Expand Up @@ -1140,7 +1157,7 @@ func (s *WorkerDeploymentSuite) TestSetWorkerDeploymentRampingVersion_WithCurren
Name: tv.DeploymentSeries(),
CreateTime: versionCreateTime,
RoutingConfig: &deploymentpb.RoutingConfig{
RampingVersion: "",
RampingVersion: worker_versioning.UnversionedVersionId, //nolint:staticcheck // SA1019: worker versioning v0.31
RampingVersionPercentage: 0,
RampingVersionChangedTime: unsetRampingUpdateTime,
RampingVersionPercentageChangedTime: unsetRampingUpdateTime,
Expand Down Expand Up @@ -2853,7 +2870,7 @@ func (s *WorkerDeploymentSuite) setAndVerifyRampingVersionUnversionedOption(
version = worker_versioning.UnversionedVersionId
}
if unset {
version = ""
version = worker_versioning.UnversionedVersionId
percentage = 0
}
if !unversioned && !unset {
Expand Down
Loading