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

Use a separate error metric for update conflicts #113

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/controller/k8/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package k8
import (
"context"

"k8s.io/apimachinery/pkg/api/errors"

"github.com/lyft/flinkk8soperator/pkg/controller/config"
"github.com/lyft/flytestdlib/logger"
"github.com/lyft/flytestdlib/promutils"
Expand Down Expand Up @@ -55,6 +57,7 @@ func newK8ClusterMetrics(scope promutils.Scope) *k8ClusterMetrics {
createFailure: labeled.NewCounter("create_failure", "K8 object creation failed", k8ClusterScope),
updateSuccess: labeled.NewCounter("update_success", "K8 object updated successfully", k8ClusterScope),
updateFailure: labeled.NewCounter("update_failure", "K8 object update failed", k8ClusterScope),
updateConflicts: labeled.NewCounter("update_conflict", "K8 object update failed due to a conflict", k8ClusterScope),
deleteSuccess: labeled.NewCounter("delete_success", "K8 object deleted successfully", k8ClusterScope),
deleteFailure: labeled.NewCounter("delete_failure", "K8 object deletion failed", k8ClusterScope),
getDeploymentCacheHit: labeled.NewCounter("get_deployment_cache_hit", "Deployment fetched from cache", k8ClusterScope),
Expand All @@ -75,6 +78,7 @@ type k8ClusterMetrics struct {
createFailure labeled.Counter
updateSuccess labeled.Counter
updateFailure labeled.Counter
updateConflicts labeled.Counter
deleteSuccess labeled.Counter
deleteFailure labeled.Counter
getDeploymentCacheHit labeled.Counter
Expand Down Expand Up @@ -178,8 +182,13 @@ func (k *Cluster) UpdateK8Object(ctx context.Context, object runtime.Object) err
objUpdate := object.DeepCopyObject()
err := k.client.Update(ctx, objUpdate)
if err != nil {
logger.Errorf(ctx, "K8 object update failed %v", err)
k.metrics.updateFailure.Inc(ctx)
if errors.IsConflict(err) {
logger.Warnf(ctx, "Conflict while updating object")
k.metrics.updateConflicts.Inc(ctx)
} else {
logger.Errorf(ctx, "K8 object update failed %v", err)
k.metrics.updateFailure.Inc(ctx)
}
return err
}
k.metrics.updateSuccess.Inc(ctx)
Expand Down