diff --git a/CHANGELOG.md b/CHANGELOG.md index 75bdd6b279c..f7824be7232 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,8 @@ - [#2993](https://github.com/influxdb/influxdb/pull/2993): Don't log each UDP batch. - [#2994](https://github.com/influxdb/influxdb/pull/2994): Don't panic during wilcard expansion if no default database specified. - [#3002](https://github.com/influxdb/influxdb/pull/3002): Remove measurement from shard's index on DROP MEASUREMENT. -- [#3021](https://github.com/influxdb/influxdb/pull/3021): Correct set HTTP write trace logging. Thanks @vladlopes. +- [#3021](https://github.com/influxdb/influxdb/pull/3021): Correct set HTTP write trace logging. Thanks @vladlopes. +- [#3027](https://github.com/influxdb/influxdb/pull/3027): Enforce minimum retention policy duration of 1 hour. ## v0.9.0 [2015-06-11] diff --git a/cmd/influxd/run/server_test.go b/cmd/influxd/run/server_test.go index 3ca8cda06a7..20b8eeeb976 100644 --- a/cmd/influxd/run/server_test.go +++ b/cmd/influxd/run/server_test.go @@ -133,10 +133,9 @@ func TestServer_RetentionPolicyCommands(t *testing.T) { exp: `{"results":[{"series":[{"columns":["name","duration","replicaN","default"]}]}]}`, }, &Query{ - skip: true, name: "Ensure retention policy with unacceptable retention cannot be created - FIXME issue #2991", command: `CREATE RETENTION POLICY rp3 ON db0 DURATION 1s REPLICATION 1`, - exp: `{"results":[{"error":"retention policy duration needs to be at least 1h0m0s"}]}`, + exp: `{"results":[{"error":"retention policy duration must be at least 1h0m0s"}]}`, }, &Query{ name: "Check error when deleting retention policy on non-existent database", diff --git a/meta/errors.go b/meta/errors.go index b7698a51179..82c5b6895f4 100644 --- a/meta/errors.go +++ b/meta/errors.go @@ -1,6 +1,9 @@ package meta -import "errors" +import ( + "errors" + "fmt" +) var ( // ErrStoreOpen is returned when opening an already open store. @@ -52,7 +55,8 @@ var ( // ErrRetentionPolicyDurationTooLow is returned when updating a retention // policy that has a duration lower than the allowed minimum. - ErrRetentionPolicyDurationTooLow = errors.New("retention policy duration too low") + ErrRetentionPolicyDurationTooLow = errors.New(fmt.Sprintf("retention policy duration must be at least %s", + RetentionPolicyMinDuration)) // ErrReplicationFactorMismatch is returned when the replication factor // does not match the number of nodes in the cluster. This is a temporary diff --git a/meta/store.go b/meta/store.go index 52a585ac41d..ccadd3b914c 100644 --- a/meta/store.go +++ b/meta/store.go @@ -34,10 +34,11 @@ const ( // that it is coming from a remote exec client connection. const ExecMagic = "EXEC" -// Retention policy auto-create settings. +// Retention policy settings. const ( AutoCreateRetentionPolicyName = "default" AutoCreateRetentionPolicyPeriod = 0 + RetentionPolicyMinDuration = time.Hour ) // Raft configuration. @@ -717,6 +718,9 @@ func (s *Store) RetentionPolicies(database string) (a []RetentionPolicyInfo, err // CreateRetentionPolicy creates a new retention policy for a database. func (s *Store) CreateRetentionPolicy(database string, rpi *RetentionPolicyInfo) (*RetentionPolicyInfo, error) { + if rpi.Duration < RetentionPolicyMinDuration && rpi.Duration != 0 { + return nil, ErrRetentionPolicyDurationTooLow + } if err := s.exec(internal.Command_CreateRetentionPolicyCommand, internal.E_CreateRetentionPolicyCommand_Command, &internal.CreateRetentionPolicyCommand{ Database: proto.String(database),