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

Reset shard duration for influx janitor #187

Merged
merged 1 commit into from Jan 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 9 additions & 5 deletions pkg/influxdb/janitor.go
Expand Up @@ -40,16 +40,20 @@ func (j *Janitor) Cleanup() error {
ttl = 60 * time.Minute
log.Infof("influx janitor [%s]: resetting retention duration to minimum %s", j.Spec.Endpoint, ttl)
}
query := fmt.Sprintf("ALTER RETENTION POLICY default ON k8s DURATION %s", ttl)
query := fmt.Sprintf("ALTER RETENTION POLICY default ON k8s DURATION %s SHARD DURATION 0s DEFAULT", ttl)
log.Infof("influx janitor [%s]: %s", j.Spec.Endpoint, query)
_, err = client.Query(influxdb.Query{
resp, err := client.Query(influxdb.Query{
Command: query,
Database: "k8s",
})
if err == nil && resp.Err != nil {
err = resp.Err
}
if err != nil {
log.Warningf("failed to ALTER RETENTION POLICY for k8s database. Reason: %v", err)
} else {
log.Infoln("successfully ALTER-ed RETENTION POLICY for k8s database")
return err
}
return err

log.Infoln("successfully altered retention policy for k8s database")
return nil
}