Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/apis/v1/nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (in *Budget) IsActive(c clock.Clock) (bool, error) {
if err != nil {
// Should only occur if there's a discrepancy
// with the validation regex and the cron package.
return false, serrors.Wrap(fmt.Errorf("invariant violated, invalid cron"), "cron", schedule)
return false, serrors.Wrap(fmt.Errorf("invariant violated, invalid cron, %w", err), "cron", schedule)
}
// Walk back in time for the duration associated with the schedule
checkPoint := c.Now().UTC().Add(-lo.FromPtr(in.Duration).Duration)
Expand Down
8 changes: 8 additions & 0 deletions pkg/apis/v1/nodepool_budgets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,13 @@ var _ = Describe("Budgets", func() {
Expect(err).To(Succeed())
Expect(active).ToNot(BeTrue())
})
It("should return an error indicating why the cron fails to parse", func() {
// Set the date to the first monday in 2024, the best year ever
fakeClock = clock.NewFakeClock(time.Date(2024, time.January, 7, 0, 0, 0, 0, time.UTC))
budgets[0].Schedule = lo.ToPtr("0 0 * * tue-mon")
budgets[0].Duration = lo.ToPtr(metav1.Duration{Duration: lo.Must(time.ParseDuration("6h"))})
_, err := budgets[0].IsActive(fakeClock)
Expect(err).To(MatchError(ContainSubstring("beginning of range (2) beyond end of range (1)")))
})
})
})
Loading