Skip to content

Commit

Permalink
fix(kds): don't inc KdsGenerationErrors when context canceled (#7913)
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Beaumont <[email protected]>
  • Loading branch information
michaelbeaumont authored Sep 28, 2023
1 parent 29d7e81 commit 557f437
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/kds/v2/server/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func newSyncTracker(
return err
},
OnError: func(err error) {
kdsMetrics.KdsGenerationsErrors.Inc()
kdsMetrics.KdsGenerationErrors.Inc()
log.Error(err, "OnTick() failed")
},
OnStop: func() {
Expand Down
5 changes: 3 additions & 2 deletions pkg/kds/v2/server/event_based_watchdog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
"errors"
"strings"
"time"

Expand Down Expand Up @@ -74,9 +75,9 @@ func (e *EventBasedWatchdog) Start(stop <-chan struct{}) {
e.Log.V(1).Info("reconcile", "changedTypes", changedTypes, "reason", reason)
start := core.Now()
err, changed := e.Reconciler.Reconcile(e.Ctx, e.Node, changedTypes)
if err != nil {
if err != nil && !errors.Is(err, context.Canceled) {
e.Log.Error(err, "reconcile failed", "changedTypes", changedTypes, "reason", reason)
e.Metrics.KdsGenerationsErrors.Inc()
e.Metrics.KdsGenerationErrors.Inc()
} else {
result := ResultNoChanges
if changed {
Expand Down
8 changes: 4 additions & 4 deletions pkg/kds/v2/server/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const (
)

type Metrics struct {
KdsGenerations *prometheus.SummaryVec
KdsGenerationsErrors prometheus.Counter
KdsGenerations *prometheus.SummaryVec
KdsGenerationErrors prometheus.Counter
}

func NewMetrics(metrics core_metrics.Metrics) (*Metrics, error) {
Expand All @@ -35,7 +35,7 @@ func NewMetrics(metrics core_metrics.Metrics) (*Metrics, error) {
}

return &Metrics{
KdsGenerations: kdsGenerations,
KdsGenerationsErrors: kdsGenerationsErrors,
KdsGenerations: kdsGenerations,
KdsGenerationErrors: kdsGenerationsErrors,
}, nil
}

0 comments on commit 557f437

Please sign in to comment.