Remove code made unnecessary by apimachinery validation

This commit is contained in:
John Gardiner Myers 2020-01-27 20:35:29 -08:00
parent ebfcf5d909
commit 38b7219b14
2 changed files with 2 additions and 21 deletions

View File

@ -51,16 +51,12 @@ func resolveSettings(cluster *kops.Cluster, group *kops.InstanceGroup, numInstan
if rollingUpdate.MaxSurge.Type == intstr.Int && rollingUpdate.MaxSurge.IntVal == 0 {
maxUnavailableDefault = intstr.FromInt(1)
}
if rollingUpdate.MaxUnavailable == nil || rollingUpdate.MaxUnavailable.IntVal < 0 {
if rollingUpdate.MaxUnavailable == nil {
rollingUpdate.MaxUnavailable = &maxUnavailableDefault
}
if rollingUpdate.MaxUnavailable.Type == intstr.String {
unavailable, err := intstr.GetValueFromIntOrPercent(rollingUpdate.MaxUnavailable, numInstances, false)
if err != nil {
// If unparseable use the default value
unavailable = maxUnavailableDefault.IntValue()
}
unavailable, _ := intstr.GetValueFromIntOrPercent(rollingUpdate.MaxUnavailable, numInstances, false)
if unavailable <= 0 {
// While we round down, percentages should resolve to a minimum of 1
unavailable = 1

View File

@ -138,21 +138,6 @@ func TestMaxUnavailable(t *testing.T) {
value: "100%",
expected: 10,
},
{
numInstances: 5,
value: "fnord",
expected: 1,
},
{
numInstances: 5,
value: "-3",
expected: 1,
},
{
numInstances: 5,
value: "-3%",
expected: 1,
},
} {
t.Run(fmt.Sprintf("%s %d", tc.value, tc.numInstances), func(t *testing.T) {
value := intstr.Parse(tc.value)