Skip to content

Commit

Permalink
fix: RolloutInfo
Browse files Browse the repository at this point in the history
Signed-off-by: maanugh <[email protected]>
  • Loading branch information
maanugh committed Nov 26, 2024
1 parent a92bb13 commit 870f38c
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions pkg/cmd/describe/describe_rollout.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type DescribeRolloutOptions struct {
RolloutViewerFn func(runtime.Object) (interface{}, error)
Watch bool
NoColor bool
All bool
All bool
TimeoutSeconds int
RolloutsV1beta1Client rolloutsv1beta1types.RolloutInterface
RolloutsV1alpha1Client rolloutv1alpha1types.RolloutInterface
Expand Down Expand Up @@ -290,11 +290,12 @@ func (o *DescribeRolloutOptions) clearScreen() {
}

type RolloutWorkloadRef struct {
Kind string
Name string
StableRevision string
CanaryRevision string
PodTemplateHash string
Kind string
Name string
StableRevision string
CanaryRevision string
PodTemplateHash string
CurrentStepIndex int32
}

func (o *DescribeRolloutOptions) GetResources(rollout RolloutWorkloadRef) (*WorkloadInfo, error) {
Expand Down Expand Up @@ -386,10 +387,10 @@ func (o *DescribeRolloutOptions) GetResources(rollout RolloutWorkloadRef) (*Work
fmt.Sprintf("%s=%s", labelSelectorParam, selectorParam),
}

if !o.All && rollout.Status.CanaryStatus.CurrentStepIndex != 0 {
if !o.All && rollout.CurrentStepIndex != 0 {
labelSelectors = append(labelSelectors,
fmt.Sprintf("rollouts.kruise.io/rollout-batch-id=%v",
rollout.Status.CanaryStatus.CurrentStepIndex))
rollout.CurrentStepIndex))
}

// Fetch pods
Expand Down Expand Up @@ -555,11 +556,12 @@ func extractRolloutInfo(obj interface{}) *RolloutInfo {
info.CurrentStepIndex = r.Status.CanaryStatus.CurrentStepIndex
info.CurrentStepState = string(r.Status.CanaryStatus.CurrentStepState)
info.WorkloadRef = RolloutWorkloadRef{
Kind: r.Spec.WorkloadRef.Kind,
Name: r.Spec.WorkloadRef.Name,
StableRevision: r.Status.CanaryStatus.StableRevision,
CanaryRevision: r.Status.CanaryStatus.CanaryRevision,
PodTemplateHash: r.Status.CanaryStatus.PodTemplateHash,
Kind: r.Spec.WorkloadRef.Kind,
Name: r.Spec.WorkloadRef.Name,
StableRevision: r.Status.CanaryStatus.StableRevision,
CanaryRevision: r.Status.CanaryStatus.CanaryRevision,
PodTemplateHash: r.Status.CanaryStatus.PodTemplateHash,
CurrentStepIndex: r.Status.CanaryStatus.CurrentStepIndex,
}

if r.Spec.Strategy.Canary != nil {
Expand All @@ -576,11 +578,12 @@ func extractRolloutInfo(obj interface{}) *RolloutInfo {
info.CurrentStepIndex = r.Status.CanaryStatus.CurrentStepIndex
info.CurrentStepState = string(r.Status.CanaryStatus.CurrentStepState)
info.WorkloadRef = RolloutWorkloadRef{
Kind: r.Spec.ObjectRef.WorkloadRef.Kind,
Name: r.Spec.ObjectRef.WorkloadRef.Name,
StableRevision: r.Status.CanaryStatus.StableRevision,
CanaryRevision: r.Status.CanaryStatus.CanaryRevision,
PodTemplateHash: r.Status.CanaryStatus.PodTemplateHash,
Kind: r.Spec.ObjectRef.WorkloadRef.Kind,
Name: r.Spec.ObjectRef.WorkloadRef.Name,
StableRevision: r.Status.CanaryStatus.StableRevision,
CanaryRevision: r.Status.CanaryStatus.CanaryRevision,
PodTemplateHash: r.Status.CanaryStatus.PodTemplateHash,
CurrentStepIndex: r.Status.CanaryStatus.CurrentStepIndex,
}

if r.Spec.Strategy.Canary != nil {
Expand Down

0 comments on commit 870f38c

Please sign in to comment.