Skip to content

Commit

Permalink
Fix inconsistent BuildID field name & empty TQ in intent check (#1141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushisource committed Jun 15, 2023
1 parent 1a0d5f9 commit ae9ed7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
13 changes: 7 additions & 6 deletions internal/worker_version_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type (
}
BuildIDOpAddNewCompatibleVersion struct {
BuildID string
ExistingCompatibleBuildId string
ExistingCompatibleBuildID string
MakeSetDefault bool
}
BuildIDOpPromoteSet struct {
Expand Down Expand Up @@ -102,13 +102,13 @@ func (uw *UpdateWorkerBuildIdCompatibilityOptions) validateAndConvertToProto() (
}

case *BuildIDOpAddNewCompatibleVersion:
if v.ExistingCompatibleBuildId == "" {
return nil, errors.New("missing ExistingCompatibleBuildId")
if v.ExistingCompatibleBuildID == "" {
return nil, errors.New("missing ExistingCompatibleBuildID")
}
req.Operation = &workflowservice.UpdateWorkerBuildIdCompatibilityRequest_AddNewCompatibleBuildId{
AddNewCompatibleBuildId: &workflowservice.UpdateWorkerBuildIdCompatibilityRequest_AddNewCompatibleVersion{
NewBuildId: v.BuildID,
ExistingCompatibleBuildId: v.ExistingCompatibleBuildId,
ExistingCompatibleBuildId: v.ExistingCompatibleBuildID,
MakeSetDefault: v.MakeSetDefault,
},
}
Expand Down Expand Up @@ -188,8 +188,9 @@ func determineUseCompatibleFlagForCommand(intent VersioningIntent, workerTq, Tar
if intent == VersioningIntentDefault {
useCompat = false
} else if intent == VersioningIntentUnspecified {
// If the target task queue doesn't match ours, use the default version
if workerTq != TargetTq {
// If the target task queue doesn't match ours, use the default version. Empty target counts
// as matching.
if TargetTq != "" && workerTq != TargetTq {
useCompat = false
}
}
Expand Down
4 changes: 4 additions & 0 deletions internal/worker_version_sets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,7 @@ func Test_VersioningIntent(t *testing.T) {
})
}
}

func Test_VersioningIntent_EmptyTargetTQ(t *testing.T) {
assert.Equal(t, true, determineUseCompatibleFlagForCommand(VersioningIntentUnspecified, "something", ""))
}
2 changes: 1 addition & 1 deletion test/worker_versioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (ts *WorkerVersioningTestSuite) TestManipulateVersionSets() {
TaskQueue: ts.taskQueueName,
Operation: &client.BuildIDOpAddNewCompatibleVersion{
BuildID: "1.1",
ExistingCompatibleBuildId: "1.0",
ExistingCompatibleBuildID: "1.0",
},
})
ts.NoError(err)
Expand Down

0 comments on commit ae9ed7b

Please sign in to comment.