New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG 1865779: Ensure MHC duration fields include units #666
BUG 1865779: Ensure MHC duration fields include units #666
Conversation
Units are mandatory when a time.Duration is being parsed. The regex as it was allowed durations to be optional, this has been updated to force a unit to be included.
@@ -73,7 +73,7 @@ spec: | |||
unsigned duration string of decimal numbers each with optional fraction | |||
and a unit suffix, eg "300ms", "1.5h" or "2h45m". Valid time units | |||
are "ns", "us" (or "µs"), "ms", "s", "m", "h". | |||
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h)*)+$ | |||
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the suffix optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suffix is not optional, not including a suffix causes the duration parse to fail, which is a bug we were suffering in previous releases as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just wondering if we should tighten the regex by adding a qualifier?
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ | |
pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h){1}){1}$ |
edit: updated to make it even tighter lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think adding either of these are correct:
(ns|us|µs|ms|s|m|h)
means that we must match one of these strings exactly, so for examplemss
wouldn't be a match, adding{1}
to this doesn't make it any stronger (https://regexr.com/59jkk)3h5m
is actually a valid duration that can be parsed, so swapping the final+
for a{1}
would restrict the allowed durations to a single unit'd number, which would be a subset of the allowed durations (https://play.golang.org/p/K7-gKJ6yUh8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, i guess the first case is really just a no-op. i didn't realize about the second case, that's a good point. thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a quick question
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
/retest |
2 similar comments
/retest |
/retest |
@JoelSpeed: This pull request references Bugzilla bug 1865779, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: enxebre The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
@JoelSpeed: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
@JoelSpeed: All pull requests linked via external trackers have merged: openshift/machine-api-operator#666. Bugzilla bug 1865779 has been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Units are mandatory when a time.Duration is being parsed. The regex as it was allowed durations to be optional, this has been updated to force a unit to be included.