fix patch rollout batch id
Signed-off-by: zhihao jian <zhihao.jian@shopee.com> add rollback prefix to identify in rollback pods fix patch rollout id fix test fix add prefix when rollout id is empty fix test
This commit is contained in:
parent
5bbbc046b0
commit
3ed3832ed6
|
|
@ -64,6 +64,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
|
||||||
obj.Status.BlueGreenStatus.UpdatedRevision = "6f8cc56547"
|
obj.Status.BlueGreenStatus.UpdatedRevision = "6f8cc56547"
|
||||||
obj.Status.BlueGreenStatus.CurrentStepIndex = 1
|
obj.Status.BlueGreenStatus.CurrentStepIndex = 1
|
||||||
obj.Status.BlueGreenStatus.NextStepIndex = 2
|
obj.Status.BlueGreenStatus.NextStepIndex = 2
|
||||||
|
obj.Status.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
obj.Status.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
obj.Status.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
||||||
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
|
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
|
||||||
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
||||||
|
|
@ -79,6 +80,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
|
||||||
s.BlueGreenStatus.CurrentStepIndex = 1
|
s.BlueGreenStatus.CurrentStepIndex = 1
|
||||||
s.BlueGreenStatus.NextStepIndex = 2
|
s.BlueGreenStatus.NextStepIndex = 2
|
||||||
s.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
s.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
||||||
|
s.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
||||||
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
||||||
util.SetRolloutCondition(s, *cond)
|
util.SetRolloutCondition(s, *cond)
|
||||||
|
|
@ -102,6 +104,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
|
||||||
}
|
}
|
||||||
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
||||||
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
|
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
|
||||||
|
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
|
||||||
return br
|
return br
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -128,6 +131,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
|
||||||
obj.Status.BlueGreenStatus.CurrentStepIndex = 1
|
obj.Status.BlueGreenStatus.CurrentStepIndex = 1
|
||||||
obj.Status.BlueGreenStatus.NextStepIndex = 2
|
obj.Status.BlueGreenStatus.NextStepIndex = 2
|
||||||
obj.Status.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
obj.Status.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
||||||
|
obj.Status.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
|
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
|
||||||
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
||||||
util.SetRolloutCondition(&obj.Status, *cond)
|
util.SetRolloutCondition(&obj.Status, *cond)
|
||||||
|
|
@ -148,6 +152,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
|
||||||
}
|
}
|
||||||
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
||||||
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
|
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
|
||||||
|
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
|
||||||
br.Status = v1beta1.BatchReleaseStatus{
|
br.Status = v1beta1.BatchReleaseStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
ObservedReleasePlanHash: util.HashReleasePlanBatches(&br.Spec.ReleasePlan),
|
ObservedReleasePlanHash: util.HashReleasePlanBatches(&br.Spec.ReleasePlan),
|
||||||
|
|
@ -171,6 +176,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
|
||||||
s.BlueGreenStatus.UpdatedReadyReplicas = 1
|
s.BlueGreenStatus.UpdatedReadyReplicas = 1
|
||||||
s.BlueGreenStatus.CurrentStepIndex = 1
|
s.BlueGreenStatus.CurrentStepIndex = 1
|
||||||
s.BlueGreenStatus.NextStepIndex = 2
|
s.BlueGreenStatus.NextStepIndex = 2
|
||||||
|
s.BlueGreenStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
s.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting
|
s.BlueGreenStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting
|
||||||
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
||||||
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
||||||
|
|
@ -195,6 +201,7 @@ func TestBlueGreenRunCanary(t *testing.T) {
|
||||||
}
|
}
|
||||||
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
||||||
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
|
br.Spec.ReleasePlan.RollingStyle = v1beta1.BlueGreenRollingStyle
|
||||||
|
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
|
||||||
return br
|
return br
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,7 @@ func TestRunCanary(t *testing.T) {
|
||||||
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
||||||
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
|
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
|
||||||
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
|
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
|
||||||
|
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
|
||||||
return br
|
return br
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -143,6 +144,7 @@ func TestRunCanary(t *testing.T) {
|
||||||
obj.Status.CanaryStatus.CurrentStepIndex = 1
|
obj.Status.CanaryStatus.CurrentStepIndex = 1
|
||||||
obj.Status.CanaryStatus.NextStepIndex = 2
|
obj.Status.CanaryStatus.NextStepIndex = 2
|
||||||
obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
obj.Status.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateUpgrade
|
||||||
|
obj.Status.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
|
cond := util.GetRolloutCondition(obj.Status, v1beta1.RolloutConditionProgressing)
|
||||||
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
||||||
util.SetRolloutCondition(&obj.Status, *cond)
|
util.SetRolloutCondition(&obj.Status, *cond)
|
||||||
|
|
@ -164,6 +166,7 @@ func TestRunCanary(t *testing.T) {
|
||||||
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
||||||
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
|
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
|
||||||
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
|
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
|
||||||
|
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
|
||||||
br.Status = v1beta1.BatchReleaseStatus{
|
br.Status = v1beta1.BatchReleaseStatus{
|
||||||
ObservedGeneration: 1,
|
ObservedGeneration: 1,
|
||||||
// since we use RollingStyle over EnableExtraWorkloadForCanary now, former hardcoded hash
|
// since we use RollingStyle over EnableExtraWorkloadForCanary now, former hardcoded hash
|
||||||
|
|
@ -190,6 +193,7 @@ func TestRunCanary(t *testing.T) {
|
||||||
s.CanaryStatus.CurrentStepIndex = 1
|
s.CanaryStatus.CurrentStepIndex = 1
|
||||||
s.CanaryStatus.NextStepIndex = 2
|
s.CanaryStatus.NextStepIndex = 2
|
||||||
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting
|
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateTrafficRouting
|
||||||
|
s.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
||||||
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
||||||
util.SetRolloutCondition(s, *cond)
|
util.SetRolloutCondition(s, *cond)
|
||||||
|
|
@ -214,6 +218,7 @@ func TestRunCanary(t *testing.T) {
|
||||||
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
br.Spec.ReleasePlan.BatchPartition = utilpointer.Int32(0)
|
||||||
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
|
br.Spec.ReleasePlan.EnableExtraWorkloadForCanary = true
|
||||||
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
|
br.Spec.ReleasePlan.RollingStyle = v1beta1.CanaryRollingStyle
|
||||||
|
br.Spec.ReleasePlan.RolloutID = "88bd5dbfd"
|
||||||
return br
|
return br
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ func TestReconcileRolloutProgressing(t *testing.T) {
|
||||||
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateInit
|
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateInit
|
||||||
s.CurrentStepIndex = s.CanaryStatus.CurrentStepIndex
|
s.CurrentStepIndex = s.CanaryStatus.CurrentStepIndex
|
||||||
s.CurrentStepState = s.CanaryStatus.CurrentStepState
|
s.CurrentStepState = s.CanaryStatus.CurrentStepState
|
||||||
|
s.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
return s
|
return s
|
||||||
},
|
},
|
||||||
expectTr: func() *v1alpha1.TrafficRouting {
|
expectTr: func() *v1alpha1.TrafficRouting {
|
||||||
|
|
@ -107,6 +108,7 @@ func TestReconcileRolloutProgressing(t *testing.T) {
|
||||||
s.CanaryStatus.CurrentStepIndex = 1
|
s.CanaryStatus.CurrentStepIndex = 1
|
||||||
s.CanaryStatus.NextStepIndex = 2
|
s.CanaryStatus.NextStepIndex = 2
|
||||||
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateInit
|
s.CanaryStatus.CurrentStepState = v1beta1.CanaryStepStateInit
|
||||||
|
s.CanaryStatus.ObservedRolloutID = "88bd5dbfd"
|
||||||
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
cond := util.GetRolloutCondition(*s, v1beta1.RolloutConditionProgressing)
|
||||||
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
cond.Reason = v1alpha1.ProgressingReasonInRolling
|
||||||
util.SetRolloutCondition(s, *cond)
|
util.SetRolloutCondition(s, *cond)
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1beta1.Rollout) (re
|
||||||
// newStatus.CanaryStatus.CurrentStepState == "Completed" {
|
// newStatus.CanaryStatus.CurrentStepState == "Completed" {
|
||||||
// // do something after rollout
|
// // do something after rollout
|
||||||
// }
|
// }
|
||||||
//```
|
// ```
|
||||||
// But at the first deployment of Rollout/Workload, CanaryStatus isn't set due to no rollout progression,
|
// 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
|
// 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.
|
// to update the status just like the rollout was completed.
|
||||||
|
|
@ -349,7 +349,14 @@ func (r *RolloutReconciler) handleFinalizer(rollout *v1beta1.Rollout) error {
|
||||||
|
|
||||||
func getRolloutID(workload *util.Workload) string {
|
func getRolloutID(workload *util.Workload) string {
|
||||||
if workload != nil {
|
if workload != nil {
|
||||||
return workload.Labels[v1beta1.RolloutIDLabel]
|
rolloutID := workload.Labels[v1beta1.RolloutIDLabel]
|
||||||
|
if rolloutID == "" {
|
||||||
|
rolloutID = workload.CanaryRevision
|
||||||
|
if workload.IsInRollback {
|
||||||
|
rolloutID = fmt.Sprintf("rollback-%s", rolloutID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rolloutID
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue