Skip to content

Commit

Permalink
fix(application): reconcile when deleted helm release (tkestack#2010) (
Browse files Browse the repository at this point in the history
…tkestack#2048)

Co-authored-by: xdonggao <[email protected]>
  • Loading branch information
GaoXiaodong and xdonggao committed Aug 5, 2022
1 parent 3914ab3 commit 565e3ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
3 changes: 2 additions & 1 deletion cmd/tke-application-controller/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import (
)

const (
defaultSyncPeriod = 30 * time.Second
// increase the sync time, because sync release from kube-apiserver
defaultSyncPeriod = 5 * time.Minute
defaultconcurrentSyncs = 10
)

Expand Down
18 changes: 2 additions & 16 deletions pkg/application/controller/app/app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,6 @@ func (c *Controller) handlePhase(ctx context.Context, key string, cachedApp *cac
}

func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedApp, app *applicationv1.App) (*applicationv1.App, error) {
if app.Status.Phase == applicationv1.AppPhaseSucceeded && hasSynced(app) {
return app, nil
}
defer func() {
if r := recover(); r != nil {
log.Error("syncAppFromRelease panic")
Expand All @@ -375,12 +372,6 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
newStatus := app.Status.DeepCopy()
rels, err := action.List(ctx, c.client.ApplicationV1(), c.platformClient, app)
if err != nil {
if app.Status.Phase == applicationv1.AppPhaseSyncFailed {
log.Error(fmt.Sprintf("sync app failed, helm list failed, err: %s", err.Error()))
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
// delayed retry, queue.AddRateLimited does not meet the demand
return app, nil
}
newStatus.Phase = applicationv1.AppPhaseSyncFailed
newStatus.Message = "sync app failed"
newStatus.Reason = err.Error()
Expand All @@ -390,13 +381,8 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
}
rel, found := helmutil.Filter(rels, app.Spec.TargetNamespace, app.Spec.Name)
if !found {
if app.Status.Phase == applicationv1.AppPhaseSyncFailed {
log.Error(fmt.Sprintf("sync app failed, release not found: %s/%s", app.Spec.TargetNamespace, app.Spec.Name))
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
// delayed retry, queue.AddRateLimited does not meet the demand
return app, nil
}
newStatus.Phase = applicationv1.AppPhaseSyncFailed
// release not found, reinstall for reconcile
newStatus.Phase = applicationv1.AppPhaseInstalling
newStatus.Message = "sync app failed"
newStatus.Reason = fmt.Sprintf("release not found: %s/%s", app.Spec.TargetNamespace, app.Spec.Name)
newStatus.LastTransitionTime = metav1.Now()
Expand Down

0 comments on commit 565e3ef

Please sign in to comment.