add status conversion
Signed-off-by: yunbo <yunbo10124scut@gmail.com>
This commit is contained in:
parent
36d5d4397a
commit
ba359f32a4
|
|
@ -114,6 +114,8 @@ func (src *Rollout) ConvertTo(dst conversion.Hub) error {
|
|||
CurrentStepState: v1beta1.CanaryStepState(src.Status.CanaryStatus.CurrentStepState),
|
||||
Message: src.Status.CanaryStatus.Message,
|
||||
LastUpdateTime: src.Status.CanaryStatus.LastUpdateTime,
|
||||
FinalisingStep: v1beta1.FinalisingStepType(src.Status.CanaryStatus.FinalisingStep),
|
||||
NextStepIndex: src.Status.CanaryStatus.NextStepIndex,
|
||||
},
|
||||
CanaryRevision: src.Status.CanaryStatus.CanaryRevision,
|
||||
CanaryReplicas: src.Status.CanaryStatus.CanaryReplicas,
|
||||
|
|
@ -258,6 +260,8 @@ func (dst *Rollout) ConvertFrom(src conversion.Hub) error {
|
|||
CurrentStepState: CanaryStepState(srcV1beta1.Status.CanaryStatus.CurrentStepState),
|
||||
Message: srcV1beta1.Status.CanaryStatus.Message,
|
||||
LastUpdateTime: srcV1beta1.Status.CanaryStatus.LastUpdateTime,
|
||||
FinalisingStep: FinalizeStateType(srcV1beta1.Status.CanaryStatus.FinalisingStep),
|
||||
NextStepIndex: srcV1beta1.Status.CanaryStatus.NextStepIndex,
|
||||
}
|
||||
return nil
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -242,6 +242,14 @@ type CanaryStatus struct {
|
|||
CanaryReplicas int32 `json:"canaryReplicas"`
|
||||
// CanaryReadyReplicas the numbers of ready canary revision pods
|
||||
CanaryReadyReplicas int32 `json:"canaryReadyReplicas"`
|
||||
// NextStepIndex defines the next step of the rollout is on.
|
||||
// In normal case, NextStepIndex is equal to CurrentStepIndex + 1
|
||||
// If the current step is the last step, NextStepIndex is equal to 0
|
||||
// Before the release, NextStepIndex is also equal to 0
|
||||
// It is allowed to modify NextStepIndex by design,
|
||||
// e.g. if CurrentStepIndex is 2, user can patch NextStepIndex to 3 (if exists) to
|
||||
// achieve batch jump, or patch NextStepIndex to 1 to implement a re-execution of step 1
|
||||
NextStepIndex int32 `json:"nextStepIndex"`
|
||||
// +optional
|
||||
CurrentStepIndex int32 `json:"currentStepIndex"`
|
||||
CurrentStepState CanaryStepState `json:"currentStepState"`
|
||||
|
|
|
|||
|
|
@ -369,10 +369,12 @@ type CommonStatus struct {
|
|||
// It is allowed to modify NextStepIndex by design,
|
||||
// e.g. if CurrentStepIndex is 2, user can patch NextStepIndex to 3 (if exists) to
|
||||
// achieve batch jump, or patch NextStepIndex to 1 to implement a re-execution of step 1
|
||||
NextStepIndex int32 `json:"nextStepIndex"`
|
||||
CurrentStepState CanaryStepState `json:"currentStepState"`
|
||||
Message string `json:"message,omitempty"`
|
||||
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
|
||||
NextStepIndex int32 `json:"nextStepIndex"`
|
||||
// FinalisingStep the step of finalising
|
||||
FinalisingStep FinalisingStepType `json:"finalisingStep"`
|
||||
CurrentStepState CanaryStepState `json:"currentStepState"`
|
||||
Message string `json:"message,omitempty"`
|
||||
LastUpdateTime *metav1.Time `json:"lastUpdateTime,omitempty"`
|
||||
}
|
||||
|
||||
// CanaryStatus status fields that only pertain to the canary rollout
|
||||
|
|
@ -386,8 +388,6 @@ type CanaryStatus struct {
|
|||
CanaryReplicas int32 `json:"canaryReplicas"`
|
||||
// CanaryReadyReplicas the numbers of ready canary revision pods
|
||||
CanaryReadyReplicas int32 `json:"canaryReadyReplicas"`
|
||||
// FinalisingStep the step of finalising
|
||||
FinalisingStep FinalisingStepType `json:"finalisingStep"`
|
||||
}
|
||||
|
||||
// BlueGreenStatus status fields that only pertain to the blueGreen rollout
|
||||
|
|
@ -395,13 +395,11 @@ type BlueGreenStatus struct {
|
|||
CommonStatus `json:",inline"`
|
||||
// CanaryRevision is calculated by rollout based on podTemplateHash, and the internal logic flow uses
|
||||
// It may be different from rs podTemplateHash in different k8s versions, so it cannot be used as service selector label
|
||||
CanaryRevision string `json:"updatedRevision"`
|
||||
UpdatedRevision string `json:"updatedRevision"`
|
||||
// UpdatedReplicas the numbers of updated pods
|
||||
UpdatedReplicas int32 `json:"updatedReplicas"`
|
||||
// UpdatedReadyReplicas the numbers of updated ready pods
|
||||
UpdatedReadyReplicas int32 `json:"updatedReadyReplicas"`
|
||||
// FinalisingStep the step of finalising
|
||||
FinalisingStep FinalisingStepType `json:"finalisingStep"`
|
||||
}
|
||||
|
||||
// GetSubStatus returns the ethier canary or bluegreen status
|
||||
|
|
@ -427,7 +425,7 @@ func (r *RolloutStatus) GetCanaryRevision() string {
|
|||
if r.CanaryStatus != nil {
|
||||
return r.CanaryStatus.CanaryRevision
|
||||
}
|
||||
return r.BlueGreenStatus.CanaryRevision
|
||||
return r.BlueGreenStatus.UpdatedRevision
|
||||
}
|
||||
|
||||
func (r *RolloutStatus) SetCanaryRevision(revision string) {
|
||||
|
|
@ -435,7 +433,7 @@ func (r *RolloutStatus) SetCanaryRevision(revision string) {
|
|||
r.CanaryStatus.CanaryRevision = revision
|
||||
}
|
||||
if r.BlueGreenStatus != nil {
|
||||
r.BlueGreenStatus.CanaryRevision = revision
|
||||
r.BlueGreenStatus.UpdatedRevision = revision
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -446,6 +446,17 @@ spec:
|
|||
type: string
|
||||
message:
|
||||
type: string
|
||||
nextStepIndex:
|
||||
description: NextStepIndex defines the next step of the rollout
|
||||
is on. In normal case, NextStepIndex is equal to CurrentStepIndex
|
||||
+ 1 If the current step is the last step, NextStepIndex is equal
|
||||
to 0 Before the release, NextStepIndex is also equal to 0 It
|
||||
is allowed to modify NextStepIndex by design, e.g. if CurrentStepIndex
|
||||
is 2, user can patch NextStepIndex to 3 (if exists) to achieve
|
||||
batch jump, or patch NextStepIndex to 1 to implement a re-execution
|
||||
of step 1
|
||||
format: int32
|
||||
type: integer
|
||||
observedRolloutID:
|
||||
description: ObservedRolloutID will record the newest spec.RolloutID
|
||||
if status.canaryRevision equals to workload.updateRevision
|
||||
|
|
@ -470,6 +481,7 @@ spec:
|
|||
- canaryRevision
|
||||
- currentStepState
|
||||
- finalisingStep
|
||||
- nextStepIndex
|
||||
- podTemplateHash
|
||||
type: object
|
||||
conditions:
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ func (r *RolloutReconciler) reconcileRolloutProgressing(rollout *v1beta1.Rollout
|
|||
CurrentStepState: v1beta1.CanaryStepStateInit,
|
||||
LastUpdateTime: &metav1.Time{Time: time.Now()},
|
||||
},
|
||||
CanaryRevision: rolloutContext.Workload.CanaryRevision,
|
||||
UpdatedRevision: rolloutContext.Workload.CanaryRevision,
|
||||
}
|
||||
} else {
|
||||
newStatus.CanaryStatus = &v1beta1.CanaryStatus{
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ func (r *RolloutReconciler) calculateRolloutStatus(rollout *v1beta1.Rollout) (re
|
|||
CurrentStepState: v1beta1.CanaryStepStateCompleted,
|
||||
RolloutHash: rollout.Annotations[util.RolloutHashAnnotation],
|
||||
},
|
||||
CanaryRevision: workload.CanaryRevision,
|
||||
UpdatedRevision: workload.CanaryRevision,
|
||||
}
|
||||
} else {
|
||||
newStatus.CanaryStatus = &v1beta1.CanaryStatus{
|
||||
|
|
|
|||
Loading…
Reference in New Issue