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

DENA-671: Update millis in one month and year #31

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions rules/msk_topic_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ const (
retentionTimeAttr = "retention.ms"
millisInOneHour = 60 * 60 * 1000
millisInOneDay = 24 * millisInOneHour
millisInOneMonth = 30 * millisInOneDay
millisInOneYear = 365 * millisInOneDay
millisInOneMonth = 2629800000
millisInOneYear = 31556952000
// The threshold on retention time when remote storage is supported.
tieredStorageThresholdInDays = 3
tieredStorageEnableAttr = "remote.storage.enable"
Expand Down
4 changes: 2 additions & 2 deletions rules/msk_topic_config_comments.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Topic configurations expressed in milliseconds must have comments explaining the
The comments can be placed after the property definition on the same line or on the line before the definition.

For computing the human-readable values it considers the following:
- 1 month has 30 days
- 1 year has 365 days
- 1 month has `2629800000` millis which is 30.4375 days
- 1 year has `31556952000` millis which is 365.2425 days

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe it would be also worth to include this information as a comment in msk_topic_config.go?


It currently checks the properties:
- retention.ms: explanation must start with `keep data`
Expand Down
12 changes: 6 additions & 6 deletions rules/msk_topic_config_comments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ resource "kafka_topic" "topic_good_retention_comment_months" {
name = "topic_good_retention_comment_months"
replication_factor = 3
config = {
"retention.ms" = "5184000000" # keep data for 2 months
"retention.ms" = "5259600000" # keep data for 2 months
}
}`,
expected: []*helper.Issue{},
Expand All @@ -111,7 +111,7 @@ resource "kafka_topic" "topic_good_retention_comment_years" {
name = "topic_good_retention_comment_years"
replication_factor = 3
config = {
"retention.ms" = "31536000000" # keep data for 1 year
"retention.ms" = "31556952000" # keep data for 1 year
}
}`,
expected: []*helper.Issue{},
Expand All @@ -123,7 +123,7 @@ resource "kafka_topic" "topic_good_retention_comment_years" {
name = "topic_good_retention_comment_years"
replication_factor = 3
config = {
"retention.ms" = "47304000000" # keep data for 1.5 years
"retention.ms" = "47335428000" # keep data for 1.5 years
}
}`,
expected: []*helper.Issue{},
Expand All @@ -135,7 +135,7 @@ resource "kafka_topic" "topic_good_retention_comment_years" {
name = "topic_good_retention_comment_years"
replication_factor = 3
config = {
"retention.ms" = "6480000000" # keep data for 2.5 months
"retention.ms" = "6574500000" # keep data for 2.5 months
}
}`,
expected: []*helper.Issue{},
Expand Down Expand Up @@ -228,14 +228,14 @@ resource "kafka_topic" "topic_def" {
name = "topic_def"
replication_factor = 3
config = {
"max.compaction.lag.ms" = "2592000000"
"max.compaction.lag.ms" = "2629800000"
}
}`, fixed: `
resource "kafka_topic" "topic_def" {
name = "topic_def"
replication_factor = 3
config = {
"max.compaction.lag.ms" = "2592000000" # allow not compacted keys maximum for 1 month
"max.compaction.lag.ms" = "2629800000" # allow not compacted keys maximum for 1 month
}
}`,
expected: []*helper.Issue{
Expand Down