Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce minimum retention policy duration #3027

Merged
merged 3 commits into from
Jun 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
3 changes: 1 addition & 2 deletions cmd/influxd/run/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 6 additions & 2 deletions meta/errors.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package meta

import "errors"
import (
"errors"
"fmt"
)

var (
// ErrStoreOpen is returned when opening an already open store.
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion meta/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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),
Expand Down