Merge pull request #3027 from influxdb/enforce_rp_duration
Enforce minimum retention policy durationpull/3020/merge
commit
6ea63626cd
|
@ -19,6 +19,7 @@
|
|||
- [#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.
|
||||
- [#3027](https://github.com/influxdb/influxdb/pull/3027): Enforce minimum retention policy duration of 1 hour.
|
||||
|
||||
## v0.9.0 [2015-06-11]
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue