Skip to content

Commit 826fe4f

Browse files
GaoXiaodongxdonggao
and
xdonggao
committed
fix(application): restore metrics when app status is successed (tkestack#2016)
Co-authored-by: xdonggao <[email protected]>
1 parent 7ebe3c1 commit 826fe4f

File tree

4 files changed

+13
-0
lines changed

4 files changed

+13
-0
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ func Install(ctx context.Context,
119119
newStatus.Reason = ""
120120
newStatus.LastTransitionTime = metav1.Now()
121121
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
122+
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
123+
metrics.GaugeApplicationRollbackFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
122124
}
123125
newApp, updateStatusErr = updateStatusFunc(ctx, newApp, &newApp.Status, newStatus)
124126
if updateStatusErr != nil {

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

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ func Rollback(ctx context.Context,
7070
newStatus.Reason = ""
7171
newStatus.LastTransitionTime = metav1.Now()
7272
newStatus.RollbackRevision = 0 // clean revision
73+
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
74+
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
7375
metrics.GaugeApplicationRollbackFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
7476
}
7577
app, updateStatusErr = updateStatusFunc(ctx, app, &app.Status, newStatus)

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

+2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ func Upgrade(ctx context.Context,
119119
newStatus.Message = ""
120120
newStatus.Reason = ""
121121
newStatus.LastTransitionTime = metav1.Now()
122+
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
122123
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
124+
metrics.GaugeApplicationRollbackFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
123125
}
124126
newApp, updateStatusErr = updateStatusFunc(ctx, newApp, &newApp.Status, newStatus)
125127
if updateStatusErr != nil {

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

+7
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ func (c *Controller) syncItem(key string) error {
260260
log.String("name", name))
261261
_ = c.processDeletion(key)
262262
err = c.appResourcesDeleter.Delete(context.Background(), namespace, name)
263+
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
264+
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
265+
metrics.GaugeApplicationRollbackFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
266+
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
263267
// If err is not nil, do not update object status when phase is Terminating.
264268
// DeletionTimestamp is not empty and object will be deleted when you request updateStatus
265269
} else {
@@ -405,6 +409,9 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
405409
newStatus.Reason = ""
406410
newStatus.LastTransitionTime = metav1.Now()
407411
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
412+
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
413+
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
414+
metrics.GaugeApplicationRollbackFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
408415

409416
newStatus.ReleaseStatus = string(rel.Info.Status)
410417
newStatus.Revision = int64(rel.Version)

0 commit comments

Comments
 (0)