Improve validation error messages for invalid Schedule cron expressions
What steps did you take and what happened:
When a Velero Schedule contains an invalid cron expression, status.validationErrors exposes low-level Go parsing errors without explaining the accepted syntax or how to correct the input.
For example, this schedule: apiVersion: velero.io/v1 kind: Schedule metadata: name: invalid-schedule namespace: velero spec: schedule: "a 0 * * *" template: includedNamespaces: - default
produces: invalid schedule: failed to parse int from "a": strconv.Atoi: parsing "a": invalid syntax
The schedule is correctly rejected, but the message repeats the parsing failure and exposes implementation details that are not useful to most users.
Steps to reproduce
- Create a Schedule with spec.schedule: "a 0 * * *".
- Wait for its phase to become FailedValidation.
- Inspect status.validationErrors.
What did you expect to happen:
Provide an actionable error that includes:
- The invalid schedule value.
- A readable explanation of the failure.
- The expected cron field order.
- Examples of valid expressions and supported shortcuts.
For example: Invalid spec.schedule "a 0 * * *": could not parse "a" as a valid cron field value. Expected a 5-field cron expression (minute hour day-of-month month day-of-week), e.g. "0 2 * * *" or "0 2 * * MON-FRI", or a supported shortcut such as "@daily" or "@every 5m". Guidance should account for supported month and weekday names, rather than imply that every field must contain an integer.
The following information will help us better understand what's going on:
If you are using velero v1.7.0+:
Please use velero debug --backup <backupname> --restore <restorename> to generate the support bundle, and attach to this issue, more options please refer to velero debug --help
If you are using earlier versions:
Please provide the output of the following commands (Pasting long output into a GitHub gist or other pastebin is fine.)
kubectl logs deployment/velero -n velerovelero backup describe <backupname>orkubectl get backup/<backupname> -n velero -o yamlvelero backup logs <backupname>velero restore describe <restorename>orkubectl get restore/<restorename> -n velero -o yamlvelero restore logs <restorename>
Anything else you would like to add:
Environment:
- Velero version (use
velero version): velero 1.18.3 - Velero features (use
velero client config get features): - Kubernetes version (use
kubectl version): - Kubernetes installer & version:
- Cloud provider or hardware configuration:
- OS (e.g. from
/etc/os-release):
Vote on this issue!
This is an invitation to the Velero community to vote on issues, you can see the project's top voted issues listed here.
Use the "reaction smiley face" up to the right of this comment to vote.
- :+1: for "I would like to see this bug fixed as soon as possible"
- :-1: for "There are more important bugs to focus on right now"
Source: velero-io/velero