From 2a656f85cc477017378b72f9003da7bfa18df44a Mon Sep 17 00:00:00 2001 From: daengdaengLee Date: Sat, 21 Sep 2024 17:18:14 +0900 Subject: [PATCH] fix: check err before use schedule and duration Signed-off-by: daengdaengLee --- pkg/apis/application/v1alpha1/types.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/apis/application/v1alpha1/types.go b/pkg/apis/application/v1alpha1/types.go index 0112ac161782e..f2d7061bb1815 100644 --- a/pkg/apis/application/v1alpha1/types.go +++ b/pkg/apis/application/v1alpha1/types.go @@ -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) } }