Skip to content

Commit

Permalink
Fix time is in Unix * 1000
Browse files Browse the repository at this point in the history
  • Loading branch information
povilasv committed Mar 19, 2019
1 parent fbd4241 commit ce62cb5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ We use *breaking* word for marking changes that are not backward compatible (rel

### Added
- [#811](https://github.com/improbable-eng/thanos/pull/811) Remote write receiver

- [#930](https://github.com/improbable-eng/thanos/pull/930) Thanos Store --skip-window
### Fixed
- [#921](https://github.com/improbable-eng/thanos/pull/921) `thanos_objstore_bucket_last_successful_upload_time` now does not appear when no blocks have been uploaded so far

Expand Down
9 changes: 3 additions & 6 deletions pkg/store/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,12 +433,9 @@ func (s *BucketStore) TimeRange() (mint, maxt int64) {
func (s *BucketStore) Info(context.Context, *storepb.InfoRequest) (*storepb.InfoResponse, error) {
mint, maxt := s.TimeRange()

if s.skipWindow != 0 {
//TODO: is TimeRange really a Unix timestamp?
newt := time.Now().Add(-s.skipWindow).Unix()
if maxt > newt {
maxt = newt
}
newt := time.Now().Add(-s.skipWindow).Truncate(1*time.Hour).Unix() * 1000
if maxt > newt {
maxt = newt
}
// Store nodes hold global data and thus have no labels.
return &storepb.InfoResponse{
Expand Down
30 changes: 30 additions & 0 deletions pkg/store/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/improbable-eng/thanos/pkg/store/storepb"
"github.com/improbable-eng/thanos/pkg/testutil"
"github.com/oklog/ulid"
"github.com/prometheus/tsdb"
"github.com/prometheus/tsdb/labels"
)

Expand Down Expand Up @@ -293,3 +294,32 @@ func TestBucketStore_Info(t *testing.T) {
testutil.Equals(t, int64(math.MaxInt64), resp.MinTime)
testutil.Equals(t, int64(math.MinInt64), resp.MaxTime)
}

func TestBucketStore_InfoSkipWindow(t *testing.T) {
defer leaktest.CheckTimeout(t, 10*time.Second)()

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

dir, err := ioutil.TempDir("", "prometheus-test")
testutil.Ok(t, err)

bucketStore, err := NewBucketStore(nil, nil, nil, dir, 2e5, 2e5, false, 20, 48*time.Hour)
testutil.Ok(t, err)

bucketStore.blocks = make(map[ulid.ULID]*bucketBlock)
bucketStore.blocks[[16]byte{0}] = &bucketBlock{
meta: &metadata.Meta{
BlockMeta: tsdb.BlockMeta{
MinTime: 1552968670000,
MaxTime: 1553004605000},
},
}

resp, err := bucketStore.Info(ctx, &storepb.InfoRequest{})
testutil.Ok(t, err)

testutil.Equals(t, storepb.StoreType_STORE, resp.StoreType)
testutil.Equals(t, int64(1552968670000), resp.MinTime)
testutil.Equals(t, time.Now().Add(-48*time.Hour).Truncate(1*time.Hour).Unix()*1000, resp.MaxTime)
}

0 comments on commit ce62cb5

Please sign in to comment.