Skip to content

Commit

Permalink
fix: check err before use schedule and duration
Browse files Browse the repository at this point in the history
Signed-off-by: daengdaengLee <gunho1020@gmail.com>
  • Loading branch information
daengdaengLee committed Sep 21, 2024
1 parent 40c6077 commit 2a656f8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/apis/application/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2427,12 +2427,18 @@ func (s *SyncWindows) inactiveAllows(currentTime time.Time) *SyncWindows {
for _, w := range *s {
if w.Kind == "allow" {
schedule, sErr := specParser.Parse(w.Schedule)
if sErr != nil {
continue
}
duration, dErr := time.ParseDuration(w.Duration)
if dErr != nil {
continue
}
// Offset the nextWindow time to consider the timeZone of the sync window
timeZoneOffsetDuration := w.scheduleOffsetByTimeZone()
nextWindow := schedule.Next(currentTime.Add(timeZoneOffsetDuration - duration))

if !nextWindow.Before(currentTime.Add(timeZoneOffsetDuration)) && sErr == nil && dErr == nil {
if !nextWindow.Before(currentTime.Add(timeZoneOffsetDuration)) {
inactive = append(inactive, w)
}
}
Expand Down

0 comments on commit 2a656f8

Please sign in to comment.