@@ -87,8 +87,8 @@ func (ra *ReconciliationActions) IsNoop() bool {
8787return ra .Create == 0 && len (ra .DeleteIDs )== 0 && ra .BackoffUntil .IsZero ()
8888}
8989
90- // MatchesCronchecks if the given time matches the cron expression
91- //Assumes the timeis already in the correct timezone
90+ // MatchesCroninterprets a cron spec as a continuous time range,
91+ //and returns whether theprovided timevalue falls within that range.
9292func MatchesCron (cronExpression string ,at time.Time ) (bool ,error ) {
9393sched ,err := cron .Weekly (cronExpression )
9494if err != nil {
@@ -98,14 +98,17 @@ func MatchesCron(cronExpression string, at time.Time) (bool, error) {
9898return sched .IsWithinRange (at ),nil
9999}
100100
101+ // CalculateDesiredInstances returns the number of desired instances based on the provided time.
102+ // If the time matches any defined autoscaling schedule, the corresponding number of instances is returned.
103+ // Otherwise, it falls back to the default number of instances specified in the prebuild configuration.
101104func (p PresetSnapshot )CalculateDesiredInstances (at time.Time ) (int32 ,error ) {
102105if ! p .Preset .AutoscalingEnabled {
103106return p .Preset .DesiredInstances .Int32 ,nil
104107}
105108
106109_ ,err := time .LoadLocation (p .Preset .AutoscalingTimezone )
107110if err != nil {
108- return 0 ,xerrors .Errorf ("can't parse location %v: %w" ,p .Preset .AutoscalingTimezone ,err )
111+ return 0 ,xerrors .Errorf ("failed to parse location %v: %w" ,p .Preset .AutoscalingTimezone ,err )
109112}
110113
111114// Check each schedule