Skip to content

Commit

Permalink
fix(application): fix sync app from release bug when status is rolled…
Browse files Browse the repository at this point in the history
…back
  • Loading branch information
xdonggao committed May 30, 2022
1 parent 009a4c2 commit 546a9ba
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pkg/application/controller/app/app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,6 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
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 All @@ -419,6 +414,15 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
newStatus.ObservedGeneration = app.Generation
// clean revision
newStatus.RollbackRevision = 0
if app.Status.Phase == applicationv1.AppPhaseRolledBack && app.Spec.Chart.ChartVersion != rel.Chart.Metadata.Version {
app.Spec.Chart.ChartVersion = rel.Chart.Metadata.Version
app.Status = *newStatus
_, 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)
}
return app, err
}
return c.updateStatus(ctx, app, &app.Status, newStatus)
}

Expand Down

0 comments on commit 546a9ba

Please sign in to comment.