-
Notifications
You must be signed in to change notification settings - Fork 7
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
per tenant retention #116
per tenant retention #116
Conversation
} | ||
|
||
// ApplyRetentionPolicyByTenant removes blocks depending on the specified retentionByTenant based on blocks MaxTime. | ||
func ApplyRetentionPolicyByTenant( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
plan to add unit test for this as well
cmd/thanos/compact.go
Outdated
@@ -436,6 +436,12 @@ func runCompact( | |||
level.Info(logger).Log("msg", "retention policy of 1 hour aggregated samples is enabled", "duration", retentionByResolution[compact.ResolutionLevel1h]) | |||
} | |||
|
|||
retentionByTenant, err := compact.ParesRetentionPolicyByTenant(logger, *conf.retentionTenants) | |||
if err != nil && len(retentionByTenant) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is len(retentionByTenant) != 0
needed here? If it's an empty config, err
should already be nil.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch
"github.com/thanos-io/objstore" | ||
|
||
"github.com/thanos-io/thanos/pkg/block" | ||
"github.com/thanos-io/thanos/pkg/block/metadata" | ||
) | ||
|
||
const ( | ||
tenantRetentionRegex = `^([\w-]+):((\d{4}-\d{2}-\d{2})|(\d+d))$` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Give some examples in a piece of code comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
examples in unit tests already
pkg/compact/retention.go
Outdated
} else if matches[3] != "" { | ||
policy.CutoffDate = cutoffDate | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: don't need else if{}
because the function returns in if{}
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still need this, matches[3]
can be empty, we allow optional cutoffDate or a retention duration
pkg/compact/retention.go
Outdated
} else if matches[4] != "" { | ||
policy.RetentionDuration = time.Duration(duration) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
c106c13
to
d2bd5b4
Compare
Signed-off-by: Yi Jin <[email protected]>
d2bd5b4
to
c3c1e59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Signed-off-by: Yi Jin <[email protected]>
56f4716
to
2cc4540
Compare
Changes
Verification