fix(chronograf/bolt): max int64 overflows 32-bit archs

pull/10616/head
Chris Goller 2018-07-25 17:50:18 -05:00
parent f510a4646d
commit 0d81058c49
1 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package bolt
import ( import (
"context" "context"
"math"
bolt "github.com/coreos/bbolt" bolt "github.com/coreos/bbolt"
"github.com/influxdata/platform/chronograf" "github.com/influxdata/platform/chronograf"
@ -15,8 +16,9 @@ var _ chronograf.SourcesStore = &SourcesStore{}
// SourcesBucket is the bolt bucket used to store source information // SourcesBucket is the bolt bucket used to store source information
var SourcesBucket = []byte("Sources") var SourcesBucket = []byte("Sources")
// DefaultSource is a temporary measure for single-binary.
var DefaultSource = &chronograf.Source{ var DefaultSource = &chronograf.Source{
ID: 9223372036854775807, // Make largest int64 so that there won't be collisions ID: math.MaxInt32, // Make largest int64 so that there won't be collisions
Name: "autogen", Name: "autogen",
Type: "influx", Type: "influx",
URL: "http://localhost:9999", URL: "http://localhost:9999",
@ -28,8 +30,8 @@ type SourcesStore struct {
client *Client client *Client
} }
// Migrate adds the default source to an existing boltdb.
func (s *SourcesStore) Migrate(ctx context.Context) error { func (s *SourcesStore) Migrate(ctx context.Context) error {
sources, err := s.All(ctx) sources, err := s.All(ctx)
if err != nil { if err != nil {
return err return err
@ -154,6 +156,7 @@ func (s *SourcesStore) all(ctx context.Context, tx *bolt.Tx) ([]chronograf.Sourc
return srcs, nil return srcs, nil
} }
// Put updates the source.
func (s *SourcesStore) Put(ctx context.Context, src *chronograf.Source) error { func (s *SourcesStore) Put(ctx context.Context, src *chronograf.Source) error {
return s.client.db.Update(func(tx *bolt.Tx) error { return s.client.db.Update(func(tx *bolt.Tx) error {
return s.put(ctx, src, tx) return s.put(ctx, src, tx)