mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Several small fixes (#550)
`if ds[i].meta.MinTime < t0 || ds[i].meta.MaxTime > t0+tr `, ds[i].meta.MinTime is always larger or equal to t0, so no need for this check. `ulid.Parse` only checks if the length is 26. So changed to using `ulid.ParseStrict` to also check the validity of ulid.
This commit is contained in:
parent
99703b3269
commit
dd0d3c6f02
|
@ -309,7 +309,7 @@ func splitByRange(ds []dirMeta, tr int64) [][]dirMeta {
|
|||
}
|
||||
// Skip blocks that don't fall into the range. This can happen via mis-alignment or
|
||||
// by being the multiple of the intended range.
|
||||
if ds[i].meta.MinTime < t0 || ds[i].meta.MaxTime > t0+tr {
|
||||
if m.MaxTime > t0+tr {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
|
@ -317,7 +317,7 @@ func splitByRange(ds []dirMeta, tr int64) [][]dirMeta {
|
|||
// Add all dirs to the current group that are within [t0, t0+tr].
|
||||
for ; i < len(ds); i++ {
|
||||
// Either the block falls into the next range or doesn't fit at all (checked above).
|
||||
if ds[i].meta.MinTime < t0 || ds[i].meta.MaxTime > t0+tr {
|
||||
if ds[i].meta.MaxTime > t0+tr {
|
||||
break
|
||||
}
|
||||
group = append(group, ds[i])
|
||||
|
|
4
db.go
4
db.go
|
@ -896,7 +896,7 @@ func (db *DB) Snapshot(dir string, withHead bool) error {
|
|||
if dir == db.dir {
|
||||
return errors.Errorf("cannot snapshot into base directory")
|
||||
}
|
||||
if _, err := ulid.Parse(dir); err == nil {
|
||||
if _, err := ulid.ParseStrict(dir); err == nil {
|
||||
return errors.Errorf("dir must not be a valid ULID")
|
||||
}
|
||||
|
||||
|
@ -1037,7 +1037,7 @@ func isBlockDir(fi os.FileInfo) bool {
|
|||
if !fi.IsDir() {
|
||||
return false
|
||||
}
|
||||
_, err := ulid.Parse(fi.Name())
|
||||
_, err := ulid.ParseStrict(fi.Name())
|
||||
return err == nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue