Skip to content

Commit 814d1f8

Browse files
authored
Merge pull request #80 from robholland/rh-ramping-version-oob
Remove Ramping version from status
2 parents ae0d5c9 + 6375ce0 commit 814d1f8

File tree

10 files changed

+576
-741
lines changed

10 files changed

+576
-741
lines changed

api/v1alpha1/worker_types.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,13 @@ type TemporalWorkerDeploymentStatus struct {
105105
// TargetVersion is the desired next version. If TargetVersion.Deployment is nil,
106106
// then the controller should create it. If not nil, the controller should
107107
// wait for it to become healthy and then move it to the CurrentVersion.
108-
TargetVersion *TargetWorkerDeploymentVersion `json:"targetVersion"`
108+
TargetVersion TargetWorkerDeploymentVersion `json:"targetVersion"`
109109

110110
// CurrentVersion is the version that is currently registered with
111111
// Temporal as the current version of its worker deployment. This will be nil
112112
// during initial bootstrap until a version is registered and set as current.
113113
CurrentVersion *CurrentWorkerDeploymentVersion `json:"currentVersion,omitempty"`
114114

115-
// RampingVersion is the version that is currently registered with
116-
// Temporal as the ramping version of its worker deployment. The controller
117-
// should ensure that this is always equal to the TargetVersion, or, if the
118-
// TargetVersion has been promoted to the current version, this should be nil.
119-
RampingVersion *TargetWorkerDeploymentVersion `json:"rampingVersion,omitempty"`
120-
121115
// DeprecatedVersions are deployment versions that are no longer the default. Any
122116
// deployment versions that are unreachable should be deleted by the controller.
123117
DeprecatedVersions []*DeprecatedWorkerDeploymentVersion `json:"deprecatedVersions,omitempty"`

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 6 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

helm/temporal-worker-controller/templates/crds/temporal.io_temporalworkerdeployments.yaml

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -3854,74 +3854,6 @@ spec:
38543854
type: array
38553855
lastModifierIdentity:
38563856
type: string
3857-
rampingVersion:
3858-
properties:
3859-
deployment:
3860-
properties:
3861-
apiVersion:
3862-
type: string
3863-
fieldPath:
3864-
type: string
3865-
kind:
3866-
type: string
3867-
name:
3868-
type: string
3869-
namespace:
3870-
type: string
3871-
resourceVersion:
3872-
type: string
3873-
uid:
3874-
type: string
3875-
type: object
3876-
x-kubernetes-map-type: atomic
3877-
healthySince:
3878-
format: date-time
3879-
type: string
3880-
managedBy:
3881-
type: string
3882-
rampLastModifiedAt:
3883-
format: date-time
3884-
type: string
3885-
rampPercentage:
3886-
type: number
3887-
rampingSince:
3888-
format: date-time
3889-
type: string
3890-
status:
3891-
type: string
3892-
taskQueues:
3893-
items:
3894-
properties:
3895-
name:
3896-
type: string
3897-
required:
3898-
- name
3899-
type: object
3900-
type: array
3901-
testWorkflows:
3902-
items:
3903-
properties:
3904-
runID:
3905-
type: string
3906-
status:
3907-
type: string
3908-
taskQueue:
3909-
type: string
3910-
workflowID:
3911-
type: string
3912-
required:
3913-
- runID
3914-
- status
3915-
- taskQueue
3916-
- workflowID
3917-
type: object
3918-
type: array
3919-
versionID:
3920-
type: string
3921-
required:
3922-
- status
3923-
- versionID
3924-
type: object
39253857
targetVersion:
39263858
properties:
39273859
deployment:

internal/controller/genplan.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
temporaliov1alpha1 "github.com/temporalio/temporal-worker-controller/api/v1alpha1"
1818
"github.com/temporalio/temporal-worker-controller/internal/k8s"
1919
"github.com/temporalio/temporal-worker-controller/internal/planner"
20+
"github.com/temporalio/temporal-worker-controller/internal/temporal"
2021
)
2122

2223
// plan holds the actions to execute during reconciliation
@@ -50,6 +51,7 @@ func (r *TemporalWorkerDeploymentReconciler) generatePlan(
5051
l logr.Logger,
5152
w *temporaliov1alpha1.TemporalWorkerDeployment,
5253
connection temporaliov1alpha1.TemporalConnectionSpec,
54+
temporalState *temporal.TemporalWorkerState,
5355
) (*plan, error) {
5456
workerDeploymentName := k8s.ComputeWorkerDeploymentName(w)
5557
targetVersionID := k8s.ComputeVersionID(w)
@@ -82,17 +84,15 @@ func (r *TemporalWorkerDeploymentReconciler) generatePlan(
8284

8385
// Generate the plan using the planner package
8486
plannerConfig := &planner.Config{
85-
Status: &w.Status,
86-
Spec: &w.Spec,
8787
RolloutStrategy: rolloutStrategy,
88-
TargetVersionID: targetVersionID,
89-
Replicas: *w.Spec.Replicas,
90-
ConflictToken: w.Status.VersionConflictToken,
9188
}
9289

9390
planResult, err := planner.GeneratePlan(
9491
l,
9592
k8sState,
93+
&w.Status,
94+
&w.Spec,
95+
temporalState,
9696
plannerConfig,
9797
)
9898
if err != nil {

internal/controller/genstatus.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func (r *TemporalWorkerDeploymentReconciler) generateStatus(
2525
temporalClient temporalClient.Client,
2626
req ctrl.Request,
2727
workerDeploy *temporaliov1alpha1.TemporalWorkerDeployment,
28+
temporalState *temporal.TemporalWorkerState,
2829
) (*temporaliov1alpha1.TemporalWorkerDeploymentStatus, error) {
2930
workerDeploymentName := k8s.ComputeWorkerDeploymentName(workerDeploy)
3031
targetVersionID := k8s.ComputeVersionID(workerDeploy)
@@ -41,17 +42,6 @@ func (r *TemporalWorkerDeploymentReconciler) generateStatus(
4142
return nil, fmt.Errorf("unable to get Kubernetes deployment state: %w", err)
4243
}
4344

44-
// Fetch Temporal worker deployment state
45-
temporalState, err := temporal.GetWorkerDeploymentState(
46-
ctx,
47-
temporalClient,
48-
workerDeploymentName,
49-
workerDeploy.Spec.WorkerOptions.TemporalNamespace,
50-
)
51-
if err != nil {
52-
return nil, fmt.Errorf("unable to get Temporal worker deployment state: %w", err)
53-
}
54-
5545
// Fetch test workflow status for the desired version
5646
if targetVersionID != temporalState.CurrentVersionID {
5747
testWorkflows, err := temporal.GetTestWorkflowStatus(

internal/controller/state_mapper.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,34 +33,25 @@ func (m *stateMapper) mapToStatus(targetVersionID string) *v1alpha1.TemporalWork
3333

3434
// Set current version
3535
currentVersionID := m.temporalState.CurrentVersionID
36-
if currentVersionID != "" {
37-
status.CurrentVersion = m.mapCurrentWorkerDeploymentVersion(currentVersionID)
38-
}
36+
status.CurrentVersion = m.mapCurrentWorkerDeploymentVersion(currentVersionID)
3937

4038
// Set target version (desired version)
4139
status.TargetVersion = m.mapTargetWorkerDeploymentVersion(targetVersionID)
42-
if status.TargetVersion != nil && m.temporalState.RampingVersionID == targetVersionID {
40+
if m.temporalState.RampingVersionID == targetVersionID {
4341
status.TargetVersion.RampingSince = m.temporalState.RampingSince
4442
status.TargetVersion.RampLastModifiedAt = m.temporalState.RampLastModifiedAt
4543
rampPercentage := m.temporalState.RampPercentage
4644
status.TargetVersion.RampPercentage = &rampPercentage
4745
}
4846

49-
rampingVersionID := m.temporalState.RampingVersionID
50-
// Set ramping version if it exists
51-
if rampingVersionID != "" {
52-
status.RampingVersion = m.mapTargetWorkerDeploymentVersion(rampingVersionID)
53-
}
54-
5547
// Add deprecated versions
5648
var deprecatedVersions []*v1alpha1.DeprecatedWorkerDeploymentVersion
5749
for versionID := range m.k8sState.Deployments {
5850
// Skip current and target versions
59-
if versionID == currentVersionID || versionID == targetVersionID || versionID == rampingVersionID {
51+
if versionID == currentVersionID || versionID == targetVersionID {
6052
continue
6153
}
6254

63-
// TODO(rob): We should never see a version here that has VersionStatusCurrent, but should we check?
6455
versionStatus := m.mapDeprecatedWorkerDeploymentVersion(versionID)
6556
if versionStatus != nil {
6657
deprecatedVersions = append(deprecatedVersions, versionStatus)
@@ -107,12 +98,8 @@ func (m *stateMapper) mapCurrentWorkerDeploymentVersion(versionID string) *v1alp
10798
}
10899

109100
// mapTargetWorkerDeploymentVersion creates a target version status from the states
110-
func (m *stateMapper) mapTargetWorkerDeploymentVersion(versionID string) *v1alpha1.TargetWorkerDeploymentVersion {
111-
if versionID == "" {
112-
return nil
113-
}
114-
115-
version := &v1alpha1.TargetWorkerDeploymentVersion{
101+
func (m *stateMapper) mapTargetWorkerDeploymentVersion(versionID string) v1alpha1.TargetWorkerDeploymentVersion {
102+
version := v1alpha1.TargetWorkerDeploymentVersion{
116103
BaseWorkerDeploymentVersion: v1alpha1.BaseWorkerDeploymentVersion{
117104
VersionID: versionID,
118105
Status: v1alpha1.VersionStatusNotRegistered,

internal/controller/state_mapper_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ func TestMapWorkerDeploymentVersion(t *testing.T) {
235235

236236
// Test target version mapping
237237
targetVersion := mapper.mapTargetWorkerDeploymentVersion("worker.v1")
238-
assert.NotNil(t, targetVersion)
239238
assert.Equal(t, "worker.v1", targetVersion.VersionID)
240239
assert.Equal(t, temporaliov1alpha1.VersionStatusCurrent, targetVersion.Status)
241240
assert.NotNil(t, targetVersion.HealthySince)

internal/controller/worker_controller.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import (
2121

2222
temporaliov1alpha1 "github.com/temporalio/temporal-worker-controller/api/v1alpha1"
2323
"github.com/temporalio/temporal-worker-controller/internal/controller/clientpool"
24+
"github.com/temporalio/temporal-worker-controller/internal/k8s"
25+
"github.com/temporalio/temporal-worker-controller/internal/temporal"
2426
)
2527

2628
var (
@@ -124,8 +126,20 @@ func (r *TemporalWorkerDeploymentReconciler) Reconcile(ctx context.Context, req
124126
temporalClient = c
125127
}
126128

129+
// Fetch Temporal worker deployment state
130+
workerDeploymentName := k8s.ComputeWorkerDeploymentName(&workerDeploy)
131+
temporalState, err := temporal.GetWorkerDeploymentState(
132+
ctx,
133+
temporalClient,
134+
workerDeploymentName,
135+
workerDeploy.Spec.WorkerOptions.TemporalNamespace,
136+
)
137+
if err != nil {
138+
return ctrl.Result{}, fmt.Errorf("unable to get Temporal worker deployment state: %w", err)
139+
}
140+
127141
// Compute a new status from k8s and temporal state
128-
status, err := r.generateStatus(ctx, l, temporalClient, req, &workerDeploy)
142+
status, err := r.generateStatus(ctx, l, temporalClient, req, &workerDeploy, temporalState)
129143
if err != nil {
130144
return ctrl.Result{}, err
131145
}
@@ -151,7 +165,7 @@ func (r *TemporalWorkerDeploymentReconciler) Reconcile(ctx context.Context, req
151165
}
152166

153167
// Generate a plan to get to desired spec from current status
154-
plan, err := r.generatePlan(ctx, l, &workerDeploy, temporalConnection.Spec)
168+
plan, err := r.generatePlan(ctx, l, &workerDeploy, temporalConnection.Spec, temporalState)
155169
if err != nil {
156170
return ctrl.Result{}, err
157171
}

0 commit comments

Comments
 (0)