Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch rollout-batch-id even without rollout-id in workload #248

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 7 additions & 0 deletions pkg/controller/rollout/rollout_bluegreen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
obj.Status.BlueGreenStatus.UpdatedRevision = "6f8cc56547"
obj.Status.BlueGreenStatus.CurrentStepIndex = 1
obj.Status.BlueGreenStatus.NextStepIndex = 2
obj.Status.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
obj.Status.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
cond.Reason = v1alpha1.ProgressingReasonInRolling
Expand All @@ -79,6 +80,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
s.BlueGreenStatus.CurrentStepIndex = 1
s.BlueGreenStatus.NextStepIndex = 2
s.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
s.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
cond.Reason = v1alpha1.ProgressingReasonInRolling
util.SetRolloutCondition(s, *cond)
Expand All @@ -102,6 +104,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
}
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
return br
},
},
Expand All @@ -128,6 +131,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
obj.Status.BlueGreenStatus.CurrentStepIndex = 1
obj.Status.BlueGreenStatus.NextStepIndex = 2
obj.Status.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
obj.Status.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
cond.Reason = v1alpha1.ProgressingReasonInRolling
util.SetRolloutCondition(&obj.Status, *cond)
Expand All @@ -148,6 +152,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
}
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
br.Status = v1beta1.BatchReleaseStatus{
ObservedGeneration: 1,
ObservedReleasePlanHash: util.HashReleasePlanBatches(&br.Spec.ReleasePlan),
Expand All @@ -171,6 +176,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
s.BlueGreenStatus.UpdatedReadyReplicas = 1
s.BlueGreenStatus.CurrentStepIndex = 1
s.BlueGreenStatus.NextStepIndex = 2
s.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
s.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
cond.Reason = v1alpha1.ProgressingReasonInRolling
Expand All @@ -195,6 +201,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
}
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
return br
},
},
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/rollout/rollout_canary_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func TestRunCanary(t *testing.T) {
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
return br
},
},
Expand Down Expand Up @@ -143,6 +144,7 @@ func TestRunCanary(t *testing.T) {
obj.Status.CanaryStatus.CurrentStepIndex = 1
obj.Status.CanaryStatus.NextStepIndex = 2
obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
obj.Status.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
cond.Reason = v1alpha1.ProgressingReasonInRolling
util.SetRolloutCondition(&obj.Status, *cond)
Expand All @@ -164,6 +166,7 @@ func TestRunCanary(t *testing.T) {
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
br.Status = v1beta1.BatchReleaseStatus{
ObservedGeneration: 1,
// since we use RollingStyle over EnableExtraWorkloadForCanary now, former hardcoded hash
Expand All @@ -190,6 +193,7 @@ func TestRunCanary(t *testing.T) {
s.CanaryStatus.CurrentStepIndex = 1
s.CanaryStatus.NextStepIndex = 2
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting
s.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
cond.Reason = v1alpha1.ProgressingReasonInRolling
util.SetRolloutCondition(s, *cond)
Expand All @@ -214,6 +218,7 @@ func TestRunCanary(t *testing.T) {
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
return br
},
},
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/rollout/rollout_progressing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestReconcileRolloutProgressing(t *testing.T) {
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateInit
s.CurrentStepIndex = s.CanaryStatus.CurrentStepIndex
s.CurrentStepState = s.CanaryStatus.CurrentStepState
s.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
return s
},
expectTr: func() *v1alpha1.TrafficRouting {
Expand Down Expand Up @@ -107,6 +108,7 @@ func TestReconcileRolloutProgressing(t *testing.T) {
s.CanaryStatus.CurrentStepIndex = 1
s.CanaryStatus.NextStepIndex = 2
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateInit
s.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
cond.Reason = v1alpha1.ProgressingReasonInRolling
util.SetRolloutCondition(s, *cond)
Expand Down
8 changes: 6 additions & 2 deletions pkg/controller/rollout/rollout_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1beta1.Rollout) (re
// newStatus.CanaryStatus.CurrentStepState == "Completed" {
// // do something after rollout
// }
//```
// ```
// But at the first deployment of Rollout/Workload, CanaryStatus isn't set due to no rollout progression,
// and PaaS platform cannot judge whether the deployment is completed base on the code above. So we have
// to update the status just like the rollout was completed.
Expand Down Expand Up @@ -349,7 +349,11 @@ func (r *RolloutReconciler) handleFinalizer(rollout *v1beta1.Rollout) error {

func getRolloutID(workload *util.Workload) string {
if workload != nil {
return workload.Labels[v1beta1.RolloutIDLabel]
rolloutID := workload.Labels[v1beta1.RolloutIDLabel]
if rolloutID == "" {
rolloutID = workload.CanaryRevision
}
return rolloutID
}
return ""
}
Loading