Skip to content

Commit

Permalink
Use UTC in es-index-cleaner (#3261)
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <[email protected]>
  • Loading branch information
pavolloffay authored Sep 13, 2021
1 parent ef8a559 commit 7756bf4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/es-index-cleaner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ func main() {
return err
}

year, month, day := time.Now().Date()
tomorrowMidnight := time.Date(year, month, day, 0, 0, 0, 0, time.Now().Location()).AddDate(0, 0, 1)
year, month, day := time.Now().UTC().Date()
tomorrowMidnight := time.Date(year, month, day, 0, 0, 0, 0, time.UTC).AddDate(0, 0, 1)
deleteIndicesBefore := tomorrowMidnight.Add(-time.Hour * 24 * time.Duration(numOfDays))
logger.Info("Indices before this date will be deleted", zap.Time("date", deleteIndicesBefore))
logger.Info("Indices before this date will be deleted", zap.String("date", deleteIndicesBefore.Format(time.RFC3339)))

filter := &app.IndexFilter{
IndexPrefix: cfg.IndexPrefix,
Expand All @@ -92,6 +92,7 @@ func main() {
Rollover: cfg.Rollover,
DeleteBeforeThisDate: deleteIndicesBefore,
}
logger.Info("Queried indices", zap.Any("indices", indices))
indices = filter.Filter(indices)

if len(indices) == 0 {
Expand Down

0 comments on commit 7756bf4

Please sign in to comment.