Skip to content

Commit

Permalink
fix(application): sync chart version in rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
leonarliu committed May 6, 2022
1 parent 4c13117 commit 13a8c38
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/application/controller/app/action/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func Rollback(ctx context.Context,
newStatus.Message = ""
newStatus.Reason = ""
newStatus.LastTransitionTime = metav1.Now()
newStatus.ObservedGeneration -= 1
newStatus.RollbackRevision = 0 // clean revision
}
app, updateStatusErr = updateStatusFunc(ctx, app, &app.Status, newStatus)
Expand Down
5 changes: 5 additions & 0 deletions pkg/application/controller/app/app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
newStatus.LastTransitionTime = metav1.Now()
return c.updateStatus(ctx, app, &app.Status, newStatus)
}
app.Spec.Chart.ChartVersion = rel.Chart.Metadata.Version
_, err = c.client.ApplicationV1().Apps(app.Namespace).Update(ctx, app, metav1.UpdateOptions{})
if err != nil {
return app, fmt.Errorf("update chart version failed %v", err)
}

newStatus.Phase = applicationv1.AppPhaseSucceeded
newStatus.Message = ""
Expand Down
2 changes: 1 addition & 1 deletion pkg/application/registry/application/storage/rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (rs *REST) Update(ctx context.Context, name string, objInfo rest.UpdatedObj
}
}

if !reflect.DeepEqual(oldApp.Spec, app.Spec) {
if !reflect.DeepEqual(oldApp.Spec, app.Spec) && app.Status.Phase != applicationapi.AppPhaseRolledBack {
app.Status.Phase = applicationapi.AppPhaseUpgrading
}

Expand Down

0 comments on commit 13a8c38

Please sign in to comment.