← Back to Pull requests

fix(cronjob): parse schedules like robfig/cron with go-cron v0.19.0 #3184

Closed
unknown closed this pull request without merging on Nov 03, 2026 20:16 UTC
View on GitHub
unknown unknown commented on Oct 28, 2026 20:18 UTC
Author

What this PR does / why we need it:

Bumps github.com/netresearch/go-cron from v0.18.0 to v0.19.0 and parses CronJob schedules with its RobfigCompat option, so KSM interprets a schedule the same way as the Kubernetes CronJob controller, which uses robfig/cron/v3.

With the standard parser, KSM and the controller disagreed:

  • Specs the API server accepts and the controller runs were reported as invalid, e.g. a step at or above the range size (/120 4-22 , 0 1 /32,1-7 3). These CronJobs had kube_cronjob_schedule_invalid set and no kube_cronjob_next_schedule_time.

  • A restricted day of month and day of week were ANDed; robfig/cron (and Vixie cron) OR them. 0 1 /32,1-7 3 next runs on Wednesday 2018-03-14 in robfig/cron, not on the first Wednesday that falls on day 1–7.
  • A day-of-week step such as 5/2 wrapped around to Sunday; robfig/cron stops at Saturday.
  • RobfigCompat combines DowOrDom, LenientSteps, EveryRoundUp, DSTSkip and DowStepToSaturday (new in v0.19.0). The parser is built once with MustNewParser, since NewParser is deprecated.

    Tests:

  • New TestParseScheduleRobfigCompat covers the lenient step, the day-of-month/day-of-week OR, the day-of-week step stopping at Saturday and @every rounding up to 1s. The expected times were checked against robfig/cron/v3 v3.0.1.

  • The two invalid-schedule cases in TestCronJobStoreScheduleParsing used specs that robfig/cron accepts, so they now use 60 and /0 , which both parsers reject.
  • How does this change affect the cardinality of KSM: does not change cardinality. CronJobs whose schedule robfig/cron accepts but the old parser rejected now emit kube_cronjob_next_schedule_time instead of kube_cronjob_schedule_invalid; each CronJob still emits one of the two.

    Which issue(s) this PR fixes: N/A

    🤖 Generated with Claude Code

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Bug Fixes
    Improved cron schedule parsing compatibility for large step values, schedules combining day-of-month and day-of-week restrictions, and sub-second @every intervals.
    Invalid schedules with out-of-range field values or zero steps continue to be rejected with wrapped parse errors.
    * Schedule parsing supports standard cron descriptors and retains timezone-aware schedules. These changes make supported schedules behave more consistently with Robfig cron timing.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 327 lines (+245 / -82) across 4 files Reviewer: dgrisonnet Review duration: 8638m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 327 lines diff across 4 files
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.347
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3184"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42% (MEDIUM) · Higher = larger blast radius
    42%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.6% · Safe to merge
    16.6%