Skip to content

Commit b290354

Browse files
committed
Remove fromAll from logs
1 parent 4a0d516 commit b290354

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

pkg/distributor/ha_tracker.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ func (h *defaultHaTracker) updateKVStoreAll(ctx context.Context, now time.Time)
474474
}
475475
// Release lock while we talk to KVStore, which could take a while.
476476
h.electedLock.RUnlock()
477-
err := uh.updateKVStore(ctx, cluster, replica, now, sampleTime, receivedAt, true)
477+
err := uh.updateKVStore(ctx, cluster, replica, now, sampleTime, receivedAt)
478478
h.electedLock.RLock()
479479
if err != nil {
480480
// Failed to store - log it but carry on
@@ -591,7 +591,7 @@ func (h *defaultHaTracker) checkReplica(ctx context.Context, userID, cluster, re
591591
}
592592

593593
uh := h.forUser(userID)
594-
err := uh.updateKVStore(ctx, cluster, replica, now, sampleTime, now.UnixMilli(), false)
594+
err := uh.updateKVStore(ctx, cluster, replica, now, sampleTime, now.UnixMilli())
595595
if err != nil {
596596
level.Error(h.logger).Log("msg", "failed to update KVStore - rejecting sample", "err", err)
597597
return err
@@ -663,7 +663,7 @@ func (h *defaultHaTracker) updateCache(userID, cluster string, desc *ReplicaDesc
663663

664664
// If we do set the value then err will be nil and desc will contain the value we set.
665665
// If there is already a valid value in the store, return nil, nil.
666-
func (h *defaultHaTrackerForUser) updateKVStore(ctx context.Context, cluster, replica string, now, sampleTime time.Time, receivedAt int64, fromAll bool) error {
666+
func (h *defaultHaTrackerForUser) updateKVStore(ctx context.Context, cluster, replica string, now, sampleTime time.Time, receivedAt int64) error {
667667
key := fmt.Sprintf("%s/%s", h.userID, cluster)
668668
var desc *ReplicaDesc
669669
var electedAtTime, electedChanges int64
@@ -692,11 +692,11 @@ func (h *defaultHaTrackerForUser) updateKVStore(ctx context.Context, cluster, re
692692
}
693693
if h.failoverSampleTimeout > 0 {
694694
if sampleTime.Sub(timestamp.Time(desc.ReceivedAt)) < h.failoverSampleTimeout {
695-
level.Info(h.logger).Log("msg", "replica differs, but it's too early to failover", "user", h.userID, "cluster", cluster, "replica", replica, "elected", desc.Replica, "received_at", timestamp.Time(desc.ReceivedAt), "sample_time", sampleTime, "failover_sample_timeout", h.failoverSampleTimeout, "from_all", fromAll)
695+
level.Info(h.logger).Log("msg", "replica differs, but it's too early to failover", "user", h.userID, "cluster", cluster, "replica", replica, "elected", desc.Replica, "received_at", timestamp.Time(desc.ReceivedAt), "sample_time", sampleTime, "failover_sample_timeout", h.failoverSampleTimeout)
696696
return nil, false, nil
697697
}
698698
}
699-
level.Info(h.logger).Log("msg", "replica differs, attempting to update kv", "user", h.userID, "cluster", cluster, "replica", replica, "elected", desc.Replica, "received_at", timestamp.Time(desc.ReceivedAt), "sample_time", sampleTime, "failover_sample_timeout", h.failoverSampleTimeout, "from_all", fromAll)
699+
level.Info(h.logger).Log("msg", "replica differs, attempting to update kv", "user", h.userID, "cluster", cluster, "replica", replica, "elected", desc.Replica, "received_at", timestamp.Time(desc.ReceivedAt), "sample_time", sampleTime, "failover_sample_timeout", h.failoverSampleTimeout)
700700
electedAtTime = timestamp.FromTime(now)
701701
electedChanges = desc.ElectedChanges + 1
702702
}

pkg/distributor/ha_tracker_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,7 @@ func TestHATracker_UserSpecificTimeouts(t *testing.T) {
15321532
now := time.Now()
15331533

15341534
// First request should succeed (establishes the replica as elected)
1535-
err = userTracker.updateKVStore(context.Background(), cluster, replica, now, now, now.UnixMilli(), false)
1535+
err = userTracker.updateKVStore(context.Background(), cluster, replica, now, now, now.UnixMilli())
15361536
assert.NoError(t, err)
15371537
tracker.electedLock.Lock()
15381538
assert.Equal(t, replica, tracker.clusters[userID][cluster].elected.Replica)
@@ -1542,7 +1542,7 @@ func TestHATracker_UserSpecificTimeouts(t *testing.T) {
15421542

15431543
// Second request within user-specific timeout should not update KV store
15441544
now = now.Add(2 * time.Second)
1545-
err = userTracker.updateKVStore(context.Background(), cluster, replica, now, now, now.UnixMilli(), false)
1545+
err = userTracker.updateKVStore(context.Background(), cluster, replica, now, now, now.UnixMilli())
15461546
assert.NoError(t, err)
15471547
tracker.electedLock.Lock()
15481548
assert.Equal(t, replica, tracker.clusters[userID][cluster].elected.Replica)
@@ -1551,23 +1551,23 @@ func TestHATracker_UserSpecificTimeouts(t *testing.T) {
15511551

15521552
// Request after user-specific timeout should trigger an update
15531553
now = now.Add(userSpecificUpdateTimeout) // Beyond user-specific timeout
1554-
err = userTracker.updateKVStore(context.Background(), cluster, replica, now, now, now.UnixMilli(), false)
1554+
err = userTracker.updateKVStore(context.Background(), cluster, replica, now, now, now.UnixMilli())
15551555
assert.NoError(t, err)
15561556
tracker.electedLock.Lock()
15571557
assert.Equal(t, replica, tracker.clusters[userID][cluster].elected.Replica)
15581558
assert.Equal(t, now.UnixMilli(), tracker.clusters[userID][cluster].elected.ReceivedAt) // Timestamp is updated
15591559
tracker.electedLock.Unlock()
15601560

15611561
// Failover shouldn't happen before FailoverTimeout
1562-
err = userTracker.updateKVStore(context.Background(), cluster, otherReplica, now, now, now.UnixMilli(), false)
1562+
err = userTracker.updateKVStore(context.Background(), cluster, otherReplica, now, now, now.UnixMilli())
15631563
assert.NoError(t, err)
15641564
tracker.electedLock.Lock()
15651565
assert.Equal(t, replica, tracker.clusters[userID][cluster].elected.Replica)
15661566
tracker.electedLock.Unlock()
15671567

15681568
// After FailoverTimeout, new value should be set
15691569
now = now.Add(userSpecificFailoverTimeout)
1570-
err = userTracker.updateKVStore(context.Background(), cluster, otherReplica, now, now, now.UnixMilli(), false)
1570+
err = userTracker.updateKVStore(context.Background(), cluster, otherReplica, now, now, now.UnixMilli())
15711571
assert.NoError(t, err)
15721572
tracker.electedLock.Lock()
15731573
assert.Equal(t, otherReplica, tracker.clusters[userID][cluster].elected.Replica)

0 commit comments

Comments
 (0)