Skip to content

Commit

Permalink
Ensure MHC duration fields include units
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JoelSpeed committed Aug 4, 2020
1 parent 66047a5 commit af2f3fc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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))+$
type: string
selector:
description: 'Label selector to match machines whose health will be
Expand Down Expand Up @@ -139,7 +139,7 @@ spec:
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))+$
type: string
type:
minLength: 1
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/machine/v1beta1/machinehealthcheck_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type MachineHealthCheckSpec struct {
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
// +optional
// +kubebuilder:default:="10m"
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h)*)+$"
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
// +kubebuilder:validation:Type:=string
NodeStartupTimeout metav1.Duration `json:"nodeStartupTimeout,omitempty"`
}
Expand All @@ -89,7 +89,7 @@ type UnhealthyCondition struct {
// Expects an 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".
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h)*)+$"
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
// +kubebuilder:validation:Type:=string
Timeout metav1.Duration `json:"timeout"`
}
Expand Down

0 comments on commit af2f3fc

Please sign in to comment.