mirror of https://github.com/kubernetes/kops.git
Workaround for time.Duration zero value
Go 1.6 has the zero value of time.Duration render to a string as `0`, but 1.7 and on renders as `0s`. Force to `0s` for consistency across versions.
This commit is contained in:
parent
493a336f35
commit
e875c27ab8
|
@ -306,7 +306,7 @@ type KubeletConfigSpec struct {
|
||||||
// Comma-delimited list of grace periods for each soft eviction signal. For example, 'memory.available=30s'.
|
// Comma-delimited list of grace periods for each soft eviction signal. For example, 'memory.available=30s'.
|
||||||
EvictionSoftGracePeriod string `json:"evictionSoftGracePeriod,omitempty" flag:"eviction-soft-grace-period"`
|
EvictionSoftGracePeriod string `json:"evictionSoftGracePeriod,omitempty" flag:"eviction-soft-grace-period"`
|
||||||
// Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition.
|
// Duration for which the kubelet has to wait before transitioning out of an eviction pressure condition.
|
||||||
EvictionPressureTransitionPeriod metav1.Duration `json:"evictionPressureTransitionPeriod,omitempty" flag:"eviction-pressure-transition-period" flag-empty:"0"`
|
EvictionPressureTransitionPeriod metav1.Duration `json:"evictionPressureTransitionPeriod,omitempty" flag:"eviction-pressure-transition-period" flag-empty:"0s"`
|
||||||
// Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met.
|
// Maximum allowed grace period (in seconds) to use when terminating pods in response to a soft eviction threshold being met.
|
||||||
EvictionMaxPodGracePeriod int32 `json:"evictionMaxPodGracePeriod,omitempty" flag:"eviction-max-pod-grace-period" flag-empty:"0"`
|
EvictionMaxPodGracePeriod int32 `json:"evictionMaxPodGracePeriod,omitempty" flag:"eviction-max-pod-grace-period" flag-empty:"0"`
|
||||||
// Comma-delimited list of minimum reclaims (e.g. imagefs.available=2Gi) that describes the minimum amount of resource the kubelet will reclaim when performing a pod eviction if that resource is under pressure.
|
// Comma-delimited list of minimum reclaims (e.g. imagefs.available=2Gi) that describes the minimum amount of resource the kubelet will reclaim when performing a pod eviction if that resource is under pressure.
|
||||||
|
|
|
@ -114,6 +114,14 @@ func BuildFlags(options interface{}) (string, error) {
|
||||||
|
|
||||||
case metav1.Duration:
|
case metav1.Duration:
|
||||||
vString := v.Duration.String()
|
vString := v.Duration.String()
|
||||||
|
|
||||||
|
// See https://github.com/kubernetes/kubernetes/issues/40783
|
||||||
|
// Go renders a time.Duration to `0` in <= 1.6, and `0s` in >= 1.7
|
||||||
|
// We force it to be `0s`, regardless of value
|
||||||
|
if vString == "0" {
|
||||||
|
vString = "0s"
|
||||||
|
}
|
||||||
|
|
||||||
if vString != flagEmpty {
|
if vString != flagEmpty {
|
||||||
flag = fmt.Sprintf("--%s=%s", flagName, vString)
|
flag = fmt.Sprintf("--%s=%s", flagName, vString)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue