Skip to content

Commit cd0c15f

Browse files
author
xdonggao
committed
fix
1 parent 6d8f08c commit cd0c15f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Diff for: pkg/application/controller/app/action/install.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package action
2020

2121
import (
2222
"context"
23+
"fmt"
2324

2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
applicationv1 "tkestack.io/tke/api/application/v1"
@@ -31,6 +32,7 @@ import (
3132
applicationprovider "tkestack.io/tke/pkg/application/provider/application"
3233
"tkestack.io/tke/pkg/application/util"
3334
chartpath "tkestack.io/tke/pkg/application/util/chartpath/v1"
35+
"tkestack.io/tke/pkg/util/log"
3436
)
3537

3638
// Install installs a chart archive
@@ -52,7 +54,12 @@ func Install(ctx context.Context,
5254
destfile, err := Pull(ctx, applicationClient, platformClient, app, repo, updateStatusFunc)
5355
if err != nil {
5456
newStatus := app.Status.DeepCopy()
55-
if updateStatusFunc != nil && app.Status.Phase != applicationv1.AppPhaseInstallFailed {
57+
if updateStatusFunc != nil {
58+
if app.Status.Phase == applicationv1.AppPhaseInstallFailed {
59+
log.Error(fmt.Sprintf("install app failed, helm pull err: %s", err.Error()))
60+
// delayed retry, queue.AddRateLimited does not meet the demand
61+
return app, nil
62+
}
5663
newStatus.Phase = applicationv1.AppPhaseInstallFailed
5764
newStatus.Message = "fetch chart failed"
5865
newStatus.Reason = err.Error()
@@ -62,8 +69,6 @@ func Install(ctx context.Context,
6269
return nil, updateStatusErr
6370
}
6471
}
65-
// delayed retry, queue.AddRateLimited does not meet the demand
66-
return app, nil
6772
}
6873

6974
newApp, err := applicationClient.Apps(app.Namespace).Get(ctx, app.Name, metav1.GetOptions{})
@@ -95,6 +100,7 @@ func Install(ctx context.Context,
95100
var updateStatusErr error
96101
if err != nil {
97102
if app.Status.Phase == applicationv1.AppPhaseInstallFailed {
103+
log.Error(fmt.Sprintf("install app failed, helm install err: %s", err.Error()))
98104
// delayed retry, queue.AddRateLimited does not meet the demand
99105
return app, nil
100106
}

Diff for: pkg/application/controller/app/action/upgrade.go

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package action
2020

2121
import (
2222
"context"
23+
"fmt"
2324

2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
applicationv1 "tkestack.io/tke/api/application/v1"
@@ -31,6 +32,7 @@ import (
3132
applicationprovider "tkestack.io/tke/pkg/application/provider/application"
3233
"tkestack.io/tke/pkg/application/util"
3334
chartpath "tkestack.io/tke/pkg/application/util/chartpath/v1"
35+
"tkestack.io/tke/pkg/util/log"
3436
)
3537

3638
// Upgrade upgrade a helm release
@@ -55,6 +57,7 @@ func Upgrade(ctx context.Context,
5557
newStatus := app.Status.DeepCopy()
5658
if updateStatusFunc != nil {
5759
if app.Status.Phase == applicationv1.AppPhaseUpgradFailed {
60+
log.Error(fmt.Sprintf("upgrade app failed, helm pull err: %s", err.Error()))
5861
// delayed retry, queue.AddRateLimited does not meet the demand
5962
return app, nil
6063
}
@@ -98,6 +101,7 @@ func Upgrade(ctx context.Context,
98101
var updateStatusErr error
99102
if err != nil {
100103
if app.Status.Phase == applicationv1.AppPhaseUpgradFailed {
104+
log.Error(fmt.Sprintf("upgrade app failed, helm upgrade err: %s", err.Error()))
101105
// delayed retry, queue.AddRateLimited does not meet the demand
102106
return app, nil
103107
}

Diff for: pkg/application/controller/app/app_controller.go

+5
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ func (c *Controller) needsUpdate(old *applicationv1.App, new *applicationv1.App)
160160
if new.Status.Phase == applicationv1.AppPhaseSyncFailed ||
161161
new.Status.Phase == applicationv1.AppPhaseInstallFailed ||
162162
new.Status.Phase == applicationv1.AppPhaseUpgradFailed ||
163+
new.Status.Phase == applicationv1.AppPhaseSucceeded ||
163164
new.Status.Phase == applicationv1.AppPhaseTerminating {
164165
return true
165166
}
@@ -371,6 +372,8 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
371372
rels, err := action.List(ctx, c.client.ApplicationV1(), c.platformClient, app)
372373
if err != nil {
373374
if app.Status.Phase == applicationv1.AppPhaseSyncFailed {
375+
log.Error(fmt.Sprintf("sync app failed, helm list failed, err: %s", err.Error()))
376+
// delayed retry, queue.AddRateLimited does not meet the demand
374377
return app, nil
375378
}
376379
newStatus.Phase = applicationv1.AppPhaseSyncFailed
@@ -382,6 +385,8 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
382385
rel, found := helmutil.Filter(rels, app.Spec.TargetNamespace, app.Spec.Name)
383386
if !found {
384387
if app.Status.Phase == applicationv1.AppPhaseSyncFailed {
388+
log.Error(fmt.Sprintf("sync app failed, release not found: %s/%s", app.Spec.TargetNamespace, app.Spec.Name))
389+
// delayed retry, queue.AddRateLimited does not meet the demand
385390
return app, nil
386391
}
387392
newStatus.Phase = applicationv1.AppPhaseSyncFailed

0 commit comments

Comments
 (0)