Skip to content

Commit

Permalink
Log prometheus config reload error instead of stopping sidecar
Browse files Browse the repository at this point in the history
Signed-off-by: Max Neverov <[email protected]>
  • Loading branch information
mneverov committed Aug 6, 2020
1 parent 2b3dd70 commit 2ec86bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
4 changes: 1 addition & 3 deletions pkg/reloader/reloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ func (r *Reloader) Watch(ctx context.Context) error {
}

if err := r.apply(ctx); err != nil {
// Critical error.
// TODO(bwplotka): There is no need to get process down in this case and decrease availability, handle the error in different way.
return err
level.Error(r.logger).Log("msg", "apply error", "err", err)
}
}
}
Expand Down
15 changes: 9 additions & 6 deletions pkg/reloader/reloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ config:
}()

reloadsSeen := 0
cnt := 0
for {
select {
case <-ctx.Done():
Expand All @@ -105,10 +106,6 @@ config:
}

rel := reloads.Load().(int)
if rel <= reloadsSeen {
// Nothing new.
continue
}

if reloadsSeen == 0 {
// Initial apply seen (without doing nothing).
Expand Down Expand Up @@ -138,8 +135,14 @@ config:
b: 2
c: 3
`, string(f))
// All good, break
break

// change the mode so reloader can't read the file.
testutil.Ok(t, os.Chmod(input, os.ModeDir))
cnt += 1
// that was the second attempt. All good, break.
if cnt == 2 {
break
}
}
reloadsSeen = rel
}
Expand Down

0 comments on commit 2ec86bf

Please sign in to comment.