diff --git a/go.mod b/go.mod index 7dba4000289..898f647769a 100644 --- a/go.mod +++ b/go.mod @@ -23,7 +23,7 @@ require ( github.com/NVIDIA/gpu-monitoring-tools v0.0.0-20180829222009-86f2a9fac6c5 github.com/NYTimes/gziphandler v1.0.1 github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e - github.com/armon/go-metrics v0.3.3 + github.com/armon/go-metrics v0.3.4 github.com/aws/aws-sdk-go v1.25.41 github.com/boltdb/bolt v1.3.1 github.com/checkpoint-restore/go-criu v0.0.0-20190109184317-bdb7599cd87b // indirect diff --git a/go.sum b/go.sum index e5027198b9a..363e7ef83fd 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1 github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= github.com/armon/go-metrics v0.0.0-20190430140413-ec5e00d3c878/go.mod h1:3AMJUQhVx52RsWOnlkpikZr01T/yAVN2gn0861vByNg= -github.com/armon/go-metrics v0.3.3 h1:a9F4rlj7EWWrbj7BYw8J8+x+ZZkJeqzNyRk8hdPF+ro= -github.com/armon/go-metrics v0.3.3/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= +github.com/armon/go-metrics v0.3.4 h1:Xqf+7f2Vhl9tsqDYmXhnXInUdcrtgpRNpIA15/uldSc= +github.com/armon/go-metrics v0.3.4/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= diff --git a/tools/go.sum b/tools/go.sum index 67950d335c3..96dbea7f8ce 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -38,8 +38,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/elazarl/go-bindata-assetfs v1.0.1-0.20200509193318-234c15e7648f h1:AwZUiMWfYSmIiHdFJIubTSs8BFIFoMmUFbeuwBzHIPs= -github.com/elazarl/go-bindata-assetfs v1.0.1-0.20200509193318-234c15e7648f/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/elazarl/go-bindata-assetfs v1.0.1 h1:m0kkaHRKEu7tUIUFVwhGGGYClXvyl4RE03qmvRTNfbw= github.com/elazarl/go-bindata-assetfs v1.0.1/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= github.com/fatih/color v1.6.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= diff --git a/vendor/github.com/armon/go-metrics/.gitignore b/vendor/github.com/armon/go-metrics/.gitignore index 8c03ec112a4..e5750f5720e 100644 --- a/vendor/github.com/armon/go-metrics/.gitignore +++ b/vendor/github.com/armon/go-metrics/.gitignore @@ -22,3 +22,5 @@ _testmain.go *.exe /metrics.out + +.idea diff --git a/vendor/github.com/armon/go-metrics/prometheus/prometheus.go b/vendor/github.com/armon/go-metrics/prometheus/prometheus.go index 8a23424fbec..66d2d32539b 100644 --- a/vendor/github.com/armon/go-metrics/prometheus/prometheus.go +++ b/vendor/github.com/armon/go-metrics/prometheus/prometheus.go @@ -5,12 +5,11 @@ package prometheus import ( "fmt" "log" + "regexp" "strings" "sync" "time" - "regexp" - "github.com/armon/go-metrics" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/push" @@ -36,10 +35,24 @@ type PrometheusSink struct { gauges sync.Map summaries sync.Map counters sync.Map - updates sync.Map expiration time.Duration } +type PrometheusGauge struct { + prometheus.Gauge + updatedAt time.Time +} + +type PrometheusSummary struct { + prometheus.Summary + updatedAt time.Time +} + +type PrometheusCounter struct { + prometheus.Counter + updatedAt time.Time +} + // NewPrometheusSink creates a new PrometheusSink using the default options. func NewPrometheusSink() (*PrometheusSink, error) { return NewPrometheusSinkFrom(DefaultPrometheusOpts) @@ -51,7 +64,6 @@ func NewPrometheusSinkFrom(opts PrometheusOpts) (*PrometheusSink, error) { gauges: sync.Map{}, summaries: sync.Map{}, counters: sync.Map{}, - updates: sync.Map{}, expiration: opts.Expiration, } @@ -72,32 +84,35 @@ func (p *PrometheusSink) Collect(c chan<- prometheus.Metric) { expire := p.expiration != 0 now := time.Now() p.gauges.Range(func(k, v interface{}) bool { - last, _ := p.updates.Load(k) - if expire && last.(time.Time).Add(p.expiration).Before(now) { - p.updates.Delete(k) - p.gauges.Delete(k) - } else { - v.(prometheus.Gauge).Collect(c) + if v != nil { + lastUpdate := v.(*PrometheusGauge).updatedAt + if expire && lastUpdate.Add(p.expiration).Before(now) { + p.gauges.Delete(k) + } else { + v.(*PrometheusGauge).Collect(c) + } } return true }) p.summaries.Range(func(k, v interface{}) bool { - last, _ := p.updates.Load(k) - if expire && last.(time.Time).Add(p.expiration).Before(now) { - p.updates.Delete(k) - p.summaries.Delete(k) - } else { - v.(prometheus.Summary).Collect(c) + if v != nil { + lastUpdate := v.(*PrometheusSummary).updatedAt + if expire && lastUpdate.Add(p.expiration).Before(now) { + p.summaries.Delete(k) + } else { + v.(*PrometheusSummary).Collect(c) + } } return true }) p.counters.Range(func(k, v interface{}) bool { - last, _ := p.updates.Load(k) - if expire && last.(time.Time).Add(p.expiration).Before(now) { - p.updates.Delete(k) - p.counters.Delete(k) - } else { - v.(prometheus.Counter).Collect(c) + if v != nil { + lastUpdate := v.(*PrometheusCounter).updatedAt + if expire && lastUpdate.Add(p.expiration).Before(now) { + p.counters.Delete(k) + } else { + v.(*PrometheusCounter).Collect(c) + } } return true }) @@ -131,17 +146,31 @@ func (p *PrometheusSink) SetGauge(parts []string, val float32) { func (p *PrometheusSink) SetGaugeWithLabels(parts []string, val float32, labels []metrics.Label) { key, hash := p.flattenKey(parts, labels) - g, ok := p.gauges.Load(hash) - if !ok { - g = prometheus.NewGauge(prometheus.GaugeOpts{ + pg, ok := p.gauges.Load(hash) + + // The sync.Map underlying gauges stores pointers to our structs. If we need to make updates, + // rather than modifying the underlying value directly, which would be racy, we make a local + // copy by dereferencing the pointer we get back, making the appropriate changes, and then + // storing a pointer to our local copy. The underlying Prometheus types are threadsafe, + // so there's no issues there. It's possible for racy updates to occur to the updatedAt + // value, but since we're always setting it to time.Now(), it doesn't really matter. + if ok { + localGauge := *pg.(*PrometheusGauge) + localGauge.Set(float64(val)) + localGauge.updatedAt = time.Now() + p.gauges.Store(hash, &localGauge) + } else { + g := prometheus.NewGauge(prometheus.GaugeOpts{ Name: key, Help: key, ConstLabels: prometheusLabels(labels), }) - p.gauges.Store(hash, g) + g.Set(float64(val)) + pg = &PrometheusGauge{ + g, time.Now(), + } + p.gauges.Store(hash, pg) } - g.(prometheus.Gauge).Set(float64(val)) - p.updates.Store(hash, time.Now()) } func (p *PrometheusSink) AddSample(parts []string, val float32) { @@ -150,19 +179,27 @@ func (p *PrometheusSink) AddSample(parts []string, val float32) { func (p *PrometheusSink) AddSampleWithLabels(parts []string, val float32, labels []metrics.Label) { key, hash := p.flattenKey(parts, labels) - g, ok := p.summaries.Load(hash) - if !ok { - g = prometheus.NewSummary(prometheus.SummaryOpts{ + ps, ok := p.summaries.Load(hash) + + if ok { + localSummary := *ps.(*PrometheusSummary) + localSummary.Observe(float64(val)) + localSummary.updatedAt = time.Now() + p.summaries.Store(hash, &localSummary) + } else { + s := prometheus.NewSummary(prometheus.SummaryOpts{ Name: key, Help: key, MaxAge: 10 * time.Second, ConstLabels: prometheusLabels(labels), Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001}, }) - p.summaries.Store(hash, g) + s.Observe(float64(val)) + ps = &PrometheusSummary{ + s, time.Now(), + } + p.summaries.Store(hash, ps) } - g.(prometheus.Summary).Observe(float64(val)) - p.updates.Store(hash, time.Now()) } // EmitKey is not implemented. Prometheus doesn’t offer a type for which an @@ -177,17 +214,25 @@ func (p *PrometheusSink) IncrCounter(parts []string, val float32) { func (p *PrometheusSink) IncrCounterWithLabels(parts []string, val float32, labels []metrics.Label) { key, hash := p.flattenKey(parts, labels) - g, ok := p.counters.Load(hash) - if !ok { - g = prometheus.NewCounter(prometheus.CounterOpts{ + pc, ok := p.counters.Load(hash) + + if ok { + localCounter := *pc.(*PrometheusCounter) + localCounter.Add(float64(val)) + localCounter.updatedAt = time.Now() + p.counters.Store(hash, &localCounter) + } else { + c := prometheus.NewCounter(prometheus.CounterOpts{ Name: key, Help: key, ConstLabels: prometheusLabels(labels), }) - p.counters.Store(hash, g) + c.Add(float64(val)) + pc = &PrometheusCounter{ + c, time.Now(), + } + p.counters.Store(hash, pc) } - g.(prometheus.Counter).Add(float64(val)) - p.updates.Store(hash, time.Now()) } type PrometheusPushSink struct { @@ -199,12 +244,10 @@ type PrometheusPushSink struct { } func NewPrometheusPushSink(address string, pushIterval time.Duration, name string) (*PrometheusPushSink, error) { - promSink := &PrometheusSink{ gauges: sync.Map{}, summaries: sync.Map{}, counters: sync.Map{}, - updates: sync.Map{}, expiration: 60 * time.Second, } diff --git a/vendor/github.com/hashicorp/nomad/api/services.go b/vendor/github.com/hashicorp/nomad/api/services.go index 1f0cf8b792b..ce6bcd9928f 100644 --- a/vendor/github.com/hashicorp/nomad/api/services.go +++ b/vendor/github.com/hashicorp/nomad/api/services.go @@ -138,6 +138,14 @@ func (s *Service) Canonicalize(t *Task, tg *TaskGroup, job *Job) { for i, check := range s.Checks { s.Checks[i].CheckRestart = s.CheckRestart.Merge(check.CheckRestart) s.Checks[i].CheckRestart.Canonicalize() + + if s.Checks[i].SuccessBeforePassing < 0 { + s.Checks[i].SuccessBeforePassing = 0 + } + + if s.Checks[i].FailuresBeforeCritical < 0 { + s.Checks[i].FailuresBeforeCritical = 0 + } } } diff --git a/vendor/github.com/hashicorp/nomad/api/tasks.go b/vendor/github.com/hashicorp/nomad/api/tasks.go index 8275813e6ee..27bbdca2d18 100644 --- a/vendor/github.com/hashicorp/nomad/api/tasks.go +++ b/vendor/github.com/hashicorp/nomad/api/tasks.go @@ -925,6 +925,7 @@ type TaskEvent struct { Time int64 DisplayMessage string Details map[string]string + Message string // DEPRECATION NOTICE: The following fields are all deprecated. see TaskEvent struct in structs.go for details. FailsTask bool RestartReason string @@ -933,7 +934,6 @@ type TaskEvent struct { DriverMessage string ExitCode int Signal int - Message string KillReason string KillTimeout time.Duration KillError string diff --git a/vendor/github.com/posener/complete/readme.md b/vendor/github.com/posener/complete/README.md similarity index 100% rename from vendor/github.com/posener/complete/readme.md rename to vendor/github.com/posener/complete/README.md diff --git a/vendor/modules.txt b/vendor/modules.txt index 342c519ed9c..a8f7e61c5d7 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -60,7 +60,7 @@ github.com/apparentlymart/go-textseg/v12/textseg # github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e ## explicit github.com/armon/circbuf -# github.com/armon/go-metrics v0.3.3 +# github.com/armon/go-metrics v0.3.4 ## explicit github.com/armon/go-metrics github.com/armon/go-metrics/circonus