1
1
package prebuilds
2
2
3
3
import (
4
+ "context"
4
5
"fmt"
5
6
"slices"
6
7
"time"
@@ -137,7 +138,13 @@ func (p PresetSnapshot) CalculateDesiredInstances(at time.Time) (int32, error) {
137
138
// Validate that the provided timezone is valid
138
139
_ , err := time .LoadLocation (p .Preset .AutoscalingTimezone )
139
140
if err != nil {
140
- return 0 , xerrors .Errorf ("failed to parse location %v: %w" , p .Preset .AutoscalingTimezone , err )
141
+ p .logger .Error (context .Background (), "invalid timezone in prebuild autoscaling configuration" ,
142
+ slog .F ("preset_id" , p .Preset .ID ),
143
+ slog .F ("timezone" , p .Preset .AutoscalingTimezone ),
144
+ slog .Error (err ))
145
+
146
+ // If timezone is invalid, fall back to the default desired instance count
147
+ return p .Preset .DesiredInstances .Int32 , nil
141
148
}
142
149
143
150
// Look for a schedule whose cron expression matches the provided time
@@ -146,7 +153,11 @@ func (p PresetSnapshot) CalculateDesiredInstances(at time.Time) (int32, error) {
146
153
cronExprWithTimezone := fmt .Sprintf ("CRON_TZ=%s %s" , p .Preset .AutoscalingTimezone , schedule .CronExpression )
147
154
matches , err := MatchesCron (cronExprWithTimezone , at )
148
155
if err != nil {
149
- return 0 , xerrors .Errorf ("failed to match cron expression: %w" , err )
156
+ p .logger .Error (context .Background (), "cron expression is invalid" ,
157
+ slog .F ("preset_id" , p .Preset .ID ),
158
+ slog .F ("cron_expression" , cronExprWithTimezone ),
159
+ slog .Error (err ))
160
+ continue
150
161
}
151
162
if matches {
152
163
return schedule .Instances , nil
0 commit comments