Skip to content

Commit

Permalink
allow idempotence when adding a task to cgroup metrics collection
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Brown <[email protected]>
  • Loading branch information
mikebrow committed Oct 18, 2018
1 parent f1f8cb0 commit 879b2ae
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions metrics/cgroups/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package cgroups

import (
"context"
"errors"
"fmt"
"sync"

Expand All @@ -33,13 +32,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
)

var (
// ErrAlreadyCollected is returned when a cgroups is already being monitored
ErrAlreadyCollected = errors.New("cgroup is already being collected")
// ErrCgroupNotExists is returns when a cgroup no longer exists
ErrCgroupNotExists = errors.New("cgroup does not exist in the collector")
)

// Trigger will be called when an event happens and provides the cgroup
// where the event originated from
type Trigger func(string, string, cgroups.Cgroup)
Expand Down Expand Up @@ -141,7 +133,7 @@ func (c *collector) Add(t runtime.Task) error {
defer c.mu.Unlock()
id := taskID(t.ID(), t.Namespace())
if _, ok := c.tasks[id]; ok {
return ErrAlreadyCollected
return nil // requests to collect metrics should be idempotent
}
c.tasks[id] = t
return nil
Expand Down

0 comments on commit 879b2ae

Please sign in to comment.