Skip to content

Commit 8b01be7

Browse files
committed
fix bootstrap bug
1 parent 27ac434 commit 8b01be7

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

internal/planner/planner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ func getVersionConfigDiff(
390390
}
391391

392392
// Do nothing if the test workflows have not completed successfully
393-
if strategy.Gate != nil {
393+
if strategy.Gate != nil && status.CurrentVersion != nil {
394394
if len(status.TargetVersion.TaskQueues) == 0 {
395395
return nil
396396
}

internal/planner/planner_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,28 @@ func TestGetTestWorkflows(t *testing.T) {
10141014
},
10151015
expectWorkflows: 0,
10161016
},
1017+
{
1018+
name: "gate workflow without current version",
1019+
status: &temporaliov1alpha1.TemporalWorkerDeploymentStatus{
1020+
TargetVersion: temporaliov1alpha1.TargetWorkerDeploymentVersion{
1021+
BaseWorkerDeploymentVersion: temporaliov1alpha1.BaseWorkerDeploymentVersion{
1022+
BuildID: "123",
1023+
Status: temporaliov1alpha1.VersionStatusInactive,
1024+
TaskQueues: []temporaliov1alpha1.TaskQueue{
1025+
{Name: "queue1"},
1026+
},
1027+
},
1028+
},
1029+
CurrentVersion: nil,
1030+
},
1031+
config: &Config{
1032+
RolloutStrategy: temporaliov1alpha1.RolloutStrategy{
1033+
Gate: &temporaliov1alpha1.GateWorkflowConfig{WorkflowType: "TestWorkflow"},
1034+
},
1035+
},
1036+
// should not start gate workflows if current version is not set. This happens when there is no initial deployment version present.
1037+
expectWorkflows: 0,
1038+
},
10171039
{
10181040
name: "all test workflows already running",
10191041
status: &temporaliov1alpha1.TemporalWorkerDeploymentStatus{
@@ -1204,6 +1226,33 @@ func TestGetVersionConfigDiff(t *testing.T) {
12041226
expectSetCurrent: true,
12051227
expectRampPercent: func() *int32 { f := int32(0); return &f }(),
12061228
},
1229+
{
1230+
name: "gate configured with no current version should set current immediately",
1231+
strategy: temporaliov1alpha1.RolloutStrategy{
1232+
Strategy: temporaliov1alpha1.UpdateProgressive,
1233+
Gate: &temporaliov1alpha1.GateWorkflowConfig{WorkflowType: "TestWorkflow"},
1234+
Steps: []temporaliov1alpha1.RolloutStep{
1235+
{RampPercentage: 1, PauseDuration: metav1Duration(30 * time.Second)},
1236+
},
1237+
},
1238+
status: &temporaliov1alpha1.TemporalWorkerDeploymentStatus{
1239+
TargetVersion: temporaliov1alpha1.TargetWorkerDeploymentVersion{
1240+
BaseWorkerDeploymentVersion: temporaliov1alpha1.BaseWorkerDeploymentVersion{
1241+
BuildID: "123",
1242+
Status: temporaliov1alpha1.VersionStatusInactive,
1243+
HealthySince: &metav1.Time{Time: time.Now()},
1244+
},
1245+
},
1246+
// CurrentVersion intentionally nil to simulate bootstrap
1247+
},
1248+
state: &temporal.TemporalWorkerState{
1249+
Versions: map[string]*temporal.VersionInfo{
1250+
"123": {BuildID: "123", AllTaskQueuesHaveUnversionedPoller: false},
1251+
},
1252+
},
1253+
expectConfig: true,
1254+
expectSetCurrent: true,
1255+
},
12071256
}
12081257

12091258
for _, tc := range testCases {

0 commit comments

Comments
 (0)