Skip to content

Commit

Permalink
Merge pull request #4737 from ch33hau/4283-hh-throws-error-even-if-di…
Browse files Browse the repository at this point in the history
…sabled

Disable HintedHandoff if configuration is not set. #4283
  • Loading branch information
corylanou committed Nov 11, 2015
2 parents 0647452 + 8bfdfbd commit 6ecb62e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -111,6 +111,7 @@
- [#4602](https://github.com/influxdb/influxdb/issues/4602): Fixes data race between PointsWriter and Subscriber services.
- [#4691](https://github.com/influxdb/influxdb/issues/4691): Enable toml test `TestConfig_Encode`.
- [#4684](https://github.com/influxdb/influxdb/pull/4684): Add Graphite and UDP section to default config. Thanks @nkatsaros
- [#4283](https://github.com/influxdb/influxdb/pull/4283): Disable HintedHandoff if configuration is not set.

## v0.9.4 [2015-09-14]

Expand Down
3 changes: 2 additions & 1 deletion cmd/influxd/run/config.go
Expand Up @@ -101,6 +101,7 @@ func NewDemoConfig() (*Config, error) {
c.HintedHandoff.Dir = filepath.Join(homeDir, ".influxdb/hh")
c.Data.WALDir = filepath.Join(homeDir, ".influxdb/wal")

c.HintedHandoff.Enabled = true
c.Admin.Enabled = true

return c, nil
Expand All @@ -110,7 +111,7 @@ func NewDemoConfig() (*Config, error) {
func (c *Config) Validate() error {
if c.Meta.Dir == "" {
return errors.New("Meta.Dir must be specified")
} else if c.HintedHandoff.Dir == "" {
} else if c.HintedHandoff.Enabled && c.HintedHandoff.Dir == "" {
return errors.New("HintedHandoff.Dir must be specified")
}

Expand Down
2 changes: 1 addition & 1 deletion services/hh/config.go
Expand Up @@ -47,7 +47,7 @@ type Config struct {

func NewConfig() Config {
return Config{
Enabled: true,
Enabled: false,
MaxSize: DefaultMaxSize,
MaxAge: toml.Duration(DefaultMaxAge),
RetryRateLimit: DefaultRetryRateLimit,
Expand Down
18 changes: 18 additions & 0 deletions services/hh/config_test.go
Expand Up @@ -53,3 +53,21 @@ purge-interval = "1h"
}

}

func TestDefaultDisabled(t *testing.T) {
// Parse empty configuration.
var c hh.Config
if _, err := toml.Decode(``, &c); err != nil {
t.Fatal(err)
}

if exp := false; c.Enabled == true {
t.Fatalf("unexpected default Enabled value: got %v, exp %v", c.Enabled, exp)
}

// Default configuration.
c = hh.NewConfig()
if exp := false; c.Enabled == true {
t.Fatalf("unexpected default enabled value: got %v, exp %v", c.Enabled, exp)
}
}

0 comments on commit 6ecb62e

Please sign in to comment.