Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove unnecessary tracker nil checking
Browse files Browse the repository at this point in the history
ying-jeanne committed Dec 19, 2024

Verified

This commit was signed with the committer’s verified signature.
viniblack Vini Black
1 parent f994034 commit b060c09
Showing 2 changed files with 3 additions and 8 deletions.
5 changes: 3 additions & 2 deletions pkg/costattribution/manager.go
Original file line number Diff line number Diff line change
@@ -109,12 +109,13 @@ func (m *Manager) deleteTracker(userID string) {
}

func (m *Manager) updateTracker(userID string) *Tracker {
if !m.EnabledForUser(userID) {
t := m.Tracker(userID)

if t == nil {
m.deleteTracker(userID)
return nil
}

t := m.Tracker(userID)
newTrackedLabels := m.limits.CostAttributionLabels(userID)

// sort the labels to ensure the order is consistent
6 changes: 0 additions & 6 deletions pkg/costattribution/tracker.go
Original file line number Diff line number Diff line change
@@ -104,9 +104,6 @@ func newTracker(userID string, trackedLabels []string, limit int, cooldown time.
}

func (t *Tracker) hasSameLabels(labels []string) bool {
if t == nil {
return len(labels) == 0
}
return slices.Equal(t.labels, labels)
}

@@ -117,9 +114,6 @@ var bufferPool = sync.Pool{
}

func (t *Tracker) cleanupTrackerAttribution(key string) {
if t == nil {
return
}
t.obseveredMtx.Lock()
defer t.obseveredMtx.Unlock()
delete(t.observed, key)

0 comments on commit b060c09

Please sign in to comment.