Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(application): fix application install metrics #1985

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions pkg/application/controller/app/action/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func Install(ctx context.Context,
if updateStatusFunc != nil {
if app.Status.Phase == applicationv1.AppPhaseInstallFailed {
log.Error(fmt.Sprintf("install app failed, helm pull err: %s", err.Error()))
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
// delayed retry, queue.AddRateLimited does not meet the demand
return app, nil
}
Expand All @@ -67,7 +67,7 @@ func Install(ctx context.Context,
newStatus.Reason = err.Error()
newStatus.LastTransitionTime = metav1.Now()
_, updateStatusErr := updateStatusFunc(ctx, app, &app.Status, newStatus)
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
if updateStatusErr != nil {
return nil, updateStatusErr
}
Expand Down Expand Up @@ -104,20 +104,21 @@ func Install(ctx context.Context,
if err != nil {
if app.Status.Phase == applicationv1.AppPhaseInstallFailed {
log.Error(fmt.Sprintf("install app failed, helm install err: %s", err.Error()))
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
// delayed retry, queue.AddRateLimited does not meet the demand
return app, nil
}
newStatus.Phase = applicationv1.AppPhaseInstallFailed
newStatus.Message = "install app failed"
newStatus.Reason = err.Error()
newStatus.LastTransitionTime = metav1.Now()
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(1)
} else {
newStatus.Phase = applicationv1.AppPhaseSucceeded
newStatus.Message = ""
newStatus.Reason = ""
newStatus.LastTransitionTime = metav1.Now()
metrics.GaugeApplicationInstallFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
}
newApp, updateStatusErr = updateStatusFunc(ctx, newApp, &newApp.Status, newStatus)
if updateStatusErr != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/application/controller/app/action/rollback.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func Rollback(ctx context.Context,
newStatus.Reason = ""
newStatus.LastTransitionTime = metav1.Now()
newStatus.RollbackRevision = 0 // clean revision
metrics.GaugeApplicationRollbackFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
}
app, updateStatusErr = updateStatusFunc(ctx, app, &app.Status, newStatus)
if updateStatusErr != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/application/controller/app/action/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ func Upgrade(ctx context.Context,
newStatus.Message = ""
newStatus.Reason = ""
newStatus.LastTransitionTime = metav1.Now()
metrics.GaugeApplicationUpgradeFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)
}
newApp, updateStatusErr = updateStatusFunc(ctx, newApp, &newApp.Status, newStatus)
if updateStatusErr != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/application/controller/app/app_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ func (c *Controller) syncAppFromRelease(ctx context.Context, cachedApp *cachedAp
newStatus.Message = ""
newStatus.Reason = ""
newStatus.LastTransitionTime = metav1.Now()
metrics.GaugeApplicationSyncFailed.WithLabelValues(app.Spec.TargetCluster, app.Name).Set(0)

newStatus.ReleaseStatus = string(rel.Info.Status)
newStatus.Revision = int64(rel.Version)
Expand Down