mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 06:04:05 -08:00
always remove tmp
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
parent
45acaadd81
commit
08e7bc8ee8
12
compact.go
12
compact.go
|
@ -493,12 +493,13 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
|
||||||
for _, w := range writers {
|
for _, w := range writers {
|
||||||
merr.Add(w.Close())
|
merr.Add(w.Close())
|
||||||
}
|
}
|
||||||
if merr.Err() != nil {
|
|
||||||
c.metrics.failed.Inc()
|
// RemoveAll returns no error when tmp doesn't exist so it is safe to always run it.
|
||||||
// TODO(gouthamve): Handle error how?
|
|
||||||
if err := os.RemoveAll(tmp); err != nil {
|
if err := os.RemoveAll(tmp); err != nil {
|
||||||
level.Error(c.logger).Log("msg", "removed tmp folder after failed compaction", "err", err.Error())
|
level.Error(c.logger).Log("msg", "removed tmp folder after failed compaction", "err", err.Error())
|
||||||
}
|
}
|
||||||
|
if merr.Err() != nil {
|
||||||
|
c.metrics.failed.Inc()
|
||||||
}
|
}
|
||||||
c.metrics.ran.Inc()
|
c.metrics.ran.Inc()
|
||||||
c.metrics.duration.Observe(time.Since(t).Seconds())
|
c.metrics.duration.Observe(time.Since(t).Seconds())
|
||||||
|
@ -559,11 +560,8 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
|
||||||
return merr.Err()
|
return merr.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populated block is empty, so cleanup and exit.
|
// Populated block is empty, so exit early.
|
||||||
if meta.Stats.NumSamples == 0 {
|
if meta.Stats.NumSamples == 0 {
|
||||||
if err := os.RemoveAll(tmp); err != nil {
|
|
||||||
return errors.Wrap(err, "remove tmp folder after empty block failed")
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue