Skip to content

Commit b149dea

Browse files
GaoXiaodongxdonggao
and
xdonggao
authored
fix(application): reconcile when deleted helm release (#2010) (#2049)
Co-authored-by: xdonggao <[email protected]>
1 parent 5a3ad56 commit b149dea

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

cmd/tke-application-controller/app/options/options.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import (
2828
)
2929

3030
const (
31-
defaultSyncPeriod = 30 * time.Second
31+
// increase the sync time, because sync release from kube-apiserver
32+
defaultSyncPeriod = 5 * time.Minute
3233
defaultconcurrentSyncs = 10
3334
)
3435

pkg/application/controller/app/app_controller.go

+2-16
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,6 @@ func (c *Controller) handlePhase(ctx context.Context, key string, cachedApp *cac
364364
}
365365

366366
func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedApp, app *applicationv1.App) (*applicationv1.App, error) {
367-
if app.Status.Phase == applicationv1.AppPhaseSucceeded && hasSynced(app) {
368-
return app, nil
369-
}
370367
defer func() {
371368
if r := recover(); r != nil {
372369
log.Error("syncAppFromRelease panic")
@@ -375,12 +372,6 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
375372
newStatus := app.Status.DeepCopy()
376373
rels, err := action.List(ctx, c.client.ApplicationV1(), c.platformClient, app)
377374
if err != nil {
378-
if app.Status.Phase == applicationv1.AppPhaseSyncFailed {
379-
log.Error(fmt.Sprintf("sync app failed, helm list failed, err: %s", err.Error()))
380-
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
381-
// delayed retry, queue.AddRateLimited does not meet the demand
382-
return app, nil
383-
}
384375
newStatus.Phase = applicationv1.AppPhaseSyncFailed
385376
newStatus.Message = "sync app failed"
386377
newStatus.Reason = err.Error()
@@ -390,13 +381,8 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
390381
}
391382
rel, found := helmutil.Filter(rels, app.Spec.TargetNamespace, app.Spec.Name)
392383
if !found {
393-
if app.Status.Phase == applicationv1.AppPhaseSyncFailed {
394-
log.Error(fmt.Sprintf("sync app failed, release not found: %s/%s", app.Spec.TargetNamespace, app.Spec.Name))
395-
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
396-
// delayed retry, queue.AddRateLimited does not meet the demand
397-
return app, nil
398-
}
399-
newStatus.Phase = applicationv1.AppPhaseSyncFailed
384+
// release not found, reinstall for reconcile
385+
newStatus.Phase = applicationv1.AppPhaseInstalling
400386
newStatus.Message = "sync app failed"
401387
newStatus.Reason = fmt.Sprintf("release not found: %s/%s", app.Spec.TargetNamespace, app.Spec.Name)
402388
newStatus.LastTransitionTime = metav1.Now()

0 commit comments

Comments
 (0)