Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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: 12 additions & 0 deletions internal/worker_deployment_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ type (
ConflictToken []byte

// PreviousVersion - The Version that was current before executing this operation, if any.
//
// Deprecated: in favor of API idempotency. Use `Describe` before this API to get the previous
// state. Pass the `ConflictToken` returned by `Describe` to this API to avoid race conditions.
PreviousVersion *WorkerDeploymentVersion
}

Expand Down Expand Up @@ -247,9 +250,15 @@ type (
ConflictToken []byte

// PreviousVersion - The Ramping Version before executing this operation, if any.
//
// Deprecated: in favor of API idempotency. Use `Describe` before this API to get the previous
// state. Pass the `ConflictToken` returned by `Describe` to this API to avoid race conditions.
PreviousVersion *WorkerDeploymentVersion

// PreviousPercentage - The Ramping Version Percentage before executing this operation.
//
// Deprecated: in favor of API idempotency. Use `Describe` before this API to get the previous
// state. Pass the `ConflictToken` returned by `Describe` to this API to avoid race conditions.
PreviousPercentage float32
}

Expand Down Expand Up @@ -298,6 +307,9 @@ type (
ConflictToken []byte

// PreviousManagerIdentity - The Manager Identity before executing this operation, if any.
//
// Deprecated: in favor of API idempotency. Use `Describe` before this API to get the previous
// state. Pass the `ConflictToken` returned by `Describe` to this API to avoid race conditions.
PreviousManagerIdentity string
}

Expand Down
15 changes: 5 additions & 10 deletions test/worker_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1072,14 +1072,13 @@ func (ts *WorkerDeploymentTestSuite) TestRampVersion_AllowNoPollers() {
ts.Error(err)

// Setting Ramp with the AllowNoPollers flag succeeds when there are no pollers
response1, err := dHandle.SetRampingVersion(ctx, client.WorkerDeploymentSetRampingVersionOptions{
_, err = dHandle.SetRampingVersion(ctx, client.WorkerDeploymentSetRampingVersionOptions{
BuildID: v1.BuildID,
ConflictToken: nil,
Percentage: float32(100.0),
AllowNoPollers: true,
})
ts.NoError(err)
ts.Nil(response1.PreviousVersion)

// Verify RoutingConfig is as expected
response2, err := dHandle.Describe(ctx, client.WorkerDeploymentDescribeOptions{})
Expand Down Expand Up @@ -1126,39 +1125,36 @@ func (ts *WorkerDeploymentTestSuite) TestSetManagerIdentity() {
ts.Equal("", response1.Info.ManagerIdentity)

// Set arbitrary ManagerIdentity
response2, err := dHandle.SetManagerIdentity(ctx, client.WorkerDeploymentSetManagerIdentityOptions{
_, err = dHandle.SetManagerIdentity(ctx, client.WorkerDeploymentSetManagerIdentityOptions{
ManagerIdentity: "foo",
ConflictToken: response1.ConflictToken,
})
ts.NoError(err)
ts.Equal("", response2.PreviousManagerIdentity)

// Check that manager identity is set to foo
response3, err := dHandle.Describe(ctx, client.WorkerDeploymentDescribeOptions{})
ts.NoError(err)
ts.Equal("foo", response3.Info.ManagerIdentity)

// Set self as ManagerIdentity
response4, err := dHandle.SetManagerIdentity(ctx, client.WorkerDeploymentSetManagerIdentityOptions{
_, err = dHandle.SetManagerIdentity(ctx, client.WorkerDeploymentSetManagerIdentityOptions{
Self: true,
Identity: "my-identity",
ConflictToken: response3.ConflictToken,
})
ts.NoError(err)
ts.Equal("foo", response4.PreviousManagerIdentity)

// Check that manager identity is set to self
response5, err := dHandle.Describe(ctx, client.WorkerDeploymentDescribeOptions{})
ts.NoError(err)
ts.Equal("my-identity", response5.Info.ManagerIdentity)

// Unset ManagerIdentity
response6, err := dHandle.SetManagerIdentity(ctx, client.WorkerDeploymentSetManagerIdentityOptions{
_, err = dHandle.SetManagerIdentity(ctx, client.WorkerDeploymentSetManagerIdentityOptions{
ManagerIdentity: "",
ConflictToken: response5.ConflictToken,
})
ts.NoError(err)
ts.Equal("my-identity", response6.PreviousManagerIdentity)

// Check that manager identity is empty
response7, err := dHandle.Describe(ctx, client.WorkerDeploymentDescribeOptions{})
Expand Down Expand Up @@ -1197,13 +1193,12 @@ func (ts *WorkerDeploymentTestSuite) TestCurrentVersion_AllowNoPollers() {
ts.Error(err)

// Setting Current with the AllowNoPollers flag succeeds when there are no pollers
response1, err := dHandle.SetCurrentVersion(ctx, client.WorkerDeploymentSetCurrentVersionOptions{
_, err = dHandle.SetCurrentVersion(ctx, client.WorkerDeploymentSetCurrentVersionOptions{
BuildID: v1.BuildID,
ConflictToken: nil,
AllowNoPollers: true,
})
ts.NoError(err)
ts.Nil(response1.PreviousVersion)

// Verify RoutingConfig is as expected
response2, err := dHandle.Describe(ctx, client.WorkerDeploymentDescribeOptions{})
Expand Down