Skip to content

Commit a6d134c

Browse files
authored
Merge pull request #824 from Icinga/retention-days-uint16
RetentionConfig: restrict days to uint16
2 parents 20fbda2 + 0eb1ad8 commit a6d134c

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ type Flags struct {
5555

5656
// RetentionConfig defines configuration for history retention.
5757
type RetentionConfig struct {
58-
HistoryDays uint64 `yaml:"history-days"`
59-
SlaDays uint64 `yaml:"sla-days"`
58+
HistoryDays uint16 `yaml:"history-days"`
59+
SlaDays uint16 `yaml:"sla-days"`
6060
Interval time.Duration `yaml:"interval" default:"1h"`
6161
Count uint64 `yaml:"count" default:"5000"`
6262
Options history.RetentionOptions `yaml:"options"`

pkg/icingadb/history/retention.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ var RetentionStatements = []retentionStatement{{
9595
}}
9696

9797
// RetentionOptions defines the non-default mapping of history categories with their retention period in days.
98-
type RetentionOptions map[string]uint64
98+
type RetentionOptions map[string]uint16
9999

100100
// Validate checks constraints in the supplied retention options and
101101
// returns an error if they are violated.
@@ -120,16 +120,16 @@ func (o RetentionOptions) Validate() error {
120120
type Retention struct {
121121
db *database.DB
122122
logger *logging.Logger
123-
historyDays uint64
124-
slaDays uint64
123+
historyDays uint16
124+
slaDays uint16
125125
interval time.Duration
126126
count uint64
127127
options RetentionOptions
128128
}
129129

130130
// NewRetention returns a new Retention.
131131
func NewRetention(
132-
db *database.DB, historyDays uint64, slaDays uint64, interval time.Duration,
132+
db *database.DB, historyDays, slaDays uint16, interval time.Duration,
133133
count uint64, options RetentionOptions, logger *logging.Logger,
134134
) *Retention {
135135
return &Retention{
@@ -156,7 +156,7 @@ func (r *Retention) Start(ctx context.Context) error {
156156
errs := make(chan error, 1)
157157

158158
for _, stmt := range RetentionStatements {
159-
var days uint64
159+
var days uint16
160160
switch stmt.RetentionType {
161161
case RetentionHistory:
162162
if d, ok := r.options[stmt.Category]; ok {
@@ -177,7 +177,7 @@ func (r *Retention) Start(ctx context.Context) error {
177177
fmt.Sprintf("Starting history retention for category %s", stmt.Category),
178178
zap.Uint64("count", r.count),
179179
zap.Duration("interval", r.interval),
180-
zap.Uint64("retention-days", days),
180+
zap.Uint16("retention-days", days),
181181
)
182182

183183
stmt := stmt

0 commit comments

Comments
 (0)