Skip to content

Commit 435a91e

Browse files
authored
Fix: Initial deployment without current version does not get promoted (#148)
<!--- Note to EXTERNAL Contributors --> <!-- Thanks for opening a PR! If it is a significant code change, please **make sure there is an open issue** for this. We work best with you when we have accepted the idea first before you code. --> <!--- For ALL Contributors 👇 --> ## What was changed - Right now, if someone were to deploy the first version of a fresh new deployment, the version keeps on being Inactive and does not get promoted to Current immediately. - Note: This only happens if there is a gated workflow specified on a TWD. This bug does not take place when there isn't a gated workflow. ## Why? - We have the following invariant: _Note that when there is no current version (as in an initial versioned worker deployment), the progressive steps are skipped and v1 becomes the current version immediately. All new workflow executions will now start on v1._ ## Checklist <!--- add/delete as needed ---> 1. Closes <!-- add issue number here --> 2. How was this tested: - Added two new unit tests. - Also tested this out locally. - Integration tests. 3. Any docs updates needed? <!--- update README if applicable or point out where to update docs.temporal.io -->
1 parent 27ac434 commit 435a91e

File tree

3 files changed

+50
-2
lines changed

3 files changed

+50
-2
lines changed

internal/planner/planner.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@ func getTestWorkflows(
339339
// Skip if there's no gate workflow defined, if the target version is already the current, or if the target
340340
// version is not yet registered in temporal
341341
if config.RolloutStrategy.Gate == nil ||
342-
status.CurrentVersion == nil ||
343-
status.CurrentVersion.BuildID == status.TargetVersion.BuildID ||
342+
(status.CurrentVersion != nil && status.CurrentVersion.BuildID == status.TargetVersion.BuildID) ||
344343
status.TargetVersion.Status == temporaliov1alpha1.VersionStatusNotRegistered {
345344
return nil
346345
}

internal/planner/planner_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,42 @@ func TestGetVersionConfigDiff(t *testing.T) {
12041204
expectSetCurrent: true,
12051205
expectRampPercent: func() *int32 { f := int32(0); return &f }(),
12061206
},
1207+
{
1208+
name: "gate configured with no current version should set current immediately",
1209+
strategy: temporaliov1alpha1.RolloutStrategy{
1210+
Strategy: temporaliov1alpha1.UpdateProgressive,
1211+
Gate: &temporaliov1alpha1.GateWorkflowConfig{WorkflowType: "TestWorkflow"},
1212+
Steps: []temporaliov1alpha1.RolloutStep{
1213+
{RampPercentage: 1, PauseDuration: metav1Duration(30 * time.Second)},
1214+
},
1215+
},
1216+
status: &temporaliov1alpha1.TemporalWorkerDeploymentStatus{
1217+
TargetVersion: temporaliov1alpha1.TargetWorkerDeploymentVersion{
1218+
BaseWorkerDeploymentVersion: temporaliov1alpha1.BaseWorkerDeploymentVersion{
1219+
BuildID: "123",
1220+
Status: temporaliov1alpha1.VersionStatusInactive,
1221+
HealthySince: &metav1.Time{Time: time.Now()},
1222+
TaskQueues: []temporaliov1alpha1.TaskQueue{
1223+
{Name: "queue1"},
1224+
},
1225+
},
1226+
TestWorkflows: []temporaliov1alpha1.WorkflowExecution{
1227+
{
1228+
TaskQueue: "queue1",
1229+
Status: temporaliov1alpha1.WorkflowExecutionStatusCompleted,
1230+
},
1231+
},
1232+
},
1233+
CurrentVersion: nil,
1234+
},
1235+
state: &temporal.TemporalWorkerState{
1236+
Versions: map[string]*temporal.VersionInfo{
1237+
"123": {BuildID: "123", AllTaskQueuesHaveUnversionedPoller: false},
1238+
},
1239+
},
1240+
expectConfig: true,
1241+
expectSetCurrent: true,
1242+
},
12071243
}
12081244

12091245
for _, tc := range testCases {

internal/tests/internal/integration_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,19 @@ func TestIntegration(t *testing.T) {
6363
WithTargetVersion("v1.0", temporaliov1alpha1.VersionStatusCurrent, -1, true, false).
6464
WithCurrentVersion("v1.0", true, false),
6565
),
66+
"progressive-rollout-with-gate-no-current-expect-all-at-once": testhelpers.NewTestCase().
67+
WithInput(
68+
testhelpers.NewTemporalWorkerDeploymentBuilder().
69+
WithProgressiveStrategy(testhelpers.ProgressiveStep(10, time.Hour)).
70+
WithReplicas(2).
71+
WithGate(true).
72+
WithTargetTemplate("v1.0"),
73+
).
74+
WithExpectedStatus(
75+
testhelpers.NewStatusBuilder().
76+
WithTargetVersion("v1.0", temporaliov1alpha1.VersionStatusCurrent, -1, true, false).
77+
WithCurrentVersion("v1.0", true, false),
78+
),
6679
"progressive-rollout-no-unversioned-pollers-expect-all-at-once": testhelpers.NewTestCase().
6780
WithInput(
6881
testhelpers.NewTemporalWorkerDeploymentBuilder().

0 commit comments

Comments
 (0)