resolve issue with promtail not scraping target if only path changed in a simpler way that dont need mutex to sync threads (#4599)

Signed-off-by: Roger Steneteg <rsteneteg@ea.com>
pull/4643/head
Roger Steneteg 4 years ago committed by GitHub
parent 6319af1ac6
commit 3b66d94e0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      clients/pkg/promtail/targets/file/filetarget.go
  2. 14
      clients/pkg/promtail/targets/file/filetargetmanager.go

@ -118,14 +118,6 @@ func (t *FileTarget) Stop() {
t.handler.Stop()
}
// UpdatePath updates the filetarget path
// returns true if the path was changed
func (t *FileTarget) UpdatePath(path string) bool {
curPath := t.path
t.path = path
return curPath != path
}
// Type implements a Target
func (t *FileTarget) Type() target.TargetType {
return target.FileTargetType

@ -243,16 +243,12 @@ func (s *targetSyncer) sync(groups []*targetgroup.Group) {
}
}
key := labels.String()
key := fmt.Sprintf("%s:%s", path, labels.String())
targets[key] = struct{}{}
if tgt, ok := s.targets[key]; ok {
if tgt.UpdatePath(string(path)) {
level.Debug(s.log).Log("msg", "updating target, path changed", "labels", labels.String())
} else {
dropped = append(dropped, target.NewDroppedTarget("ignoring target, already exists", discoveredLabels))
level.Debug(s.log).Log("msg", "ignoring target, already exists", "labels", labels.String())
s.metrics.failedTargets.WithLabelValues("exists").Inc()
}
if _, ok := s.targets[key]; ok {
dropped = append(dropped, target.NewDroppedTarget("ignoring target, already exists", discoveredLabels))
level.Debug(s.log).Log("msg", "ignoring target, already exists", "labels", labels.String())
s.metrics.failedTargets.WithLabelValues("exists").Inc()
continue
}

Loading…
Cancel
Save