Remove no-longer-needed validation

This commit is contained in:
John Gardiner Myers 2020-05-04 23:19:41 -07:00
parent 6b011c044b
commit bcb6255575
3 changed files with 0 additions and 45 deletions

View File

@ -30,7 +30,6 @@ go_library(
"//vendor/k8s.io/apimachinery/pkg/util/sets:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/util/validation/field:go_default_library",
"//vendor/k8s.io/klog:go_default_library",
],
)

View File

@ -17,13 +17,11 @@ limitations under the License.
package validation
import (
"fmt"
"strconv"
"strings"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/klog"
"k8s.io/kops/pkg/apis/kops"
"k8s.io/kops/upup/pkg/fi/cloudup/awsup"
)
@ -47,8 +45,6 @@ func awsValidateInstanceGroup(ig *kops.InstanceGroup) field.ErrorList {
allErrs = append(allErrs, awsValidateMachineType(field.NewPath(ig.GetName(), "spec", "machineType"), ig.Spec.MachineType)...)
allErrs = append(allErrs, awsValidateAMIforNVMe(field.NewPath(ig.GetName(), "spec", "machineType"), ig)...)
allErrs = append(allErrs, awsValidateSpotDurationInMinute(field.NewPath(ig.GetName(), "spec", "spotDurationInMinutes"), ig)...)
return allErrs
@ -89,28 +85,6 @@ func awsValidateMachineType(fieldPath *field.Path, machineType string) field.Err
return allErrs
}
// TODO: make image validation smarter? graduate from jessie to stretch? This is quick and dirty because we keep getting reports
func awsValidateAMIforNVMe(fieldPath *field.Path, ig *kops.InstanceGroup) field.ErrorList {
// TODO: how can we put this list somewhere better?
NVMe_INSTANCE_PREFIXES := []string{"P3", "C5", "M5", "H1", "I3"}
allErrs := field.ErrorList{}
for _, prefix := range NVMe_INSTANCE_PREFIXES {
for _, machineType := range strings.Split(ig.Spec.MachineType, ",") {
if strings.Contains(strings.ToUpper(machineType), strings.ToUpper(prefix)) {
klog.V(2).Infof("machineType %s requires an image based on stretch to operate. Trying to check compatibility", machineType)
if strings.Contains(ig.Spec.Image, "jessie") {
errString := fmt.Sprintf("%s cannot use machineType %s with image based on Debian jessie.", ig.Name, machineType)
allErrs = append(allErrs, field.Forbidden(fieldPath, errString))
continue
}
}
}
}
return allErrs
}
func awsValidateSpotDurationInMinute(fieldPath *field.Path, ig *kops.InstanceGroup) field.ErrorList {
allErrs := field.ErrorList{}
if ig.Spec.SpotDurationInMinutes != nil {

View File

@ -79,15 +79,6 @@ func TestValidateInstanceGroupSpec(t *testing.T) {
},
ExpectedErrors: []string{},
},
{
Input: kops.InstanceGroupSpec{
MachineType: "m5.large",
Image: "k8s-1.9-debian-jessie-amd64-hvm-ebs-2018-03-11",
},
ExpectedErrors: []string{
"Forbidden::test-nodes.spec.machineType",
},
},
{
Input: kops.InstanceGroupSpec{
MachineType: "c5.large",
@ -95,15 +86,6 @@ func TestValidateInstanceGroupSpec(t *testing.T) {
},
ExpectedErrors: []string{},
},
{
Input: kops.InstanceGroupSpec{
MachineType: "c5.large",
Image: "k8s-1.9-debian-jessie-amd64-hvm-ebs-2018-03-11",
},
ExpectedErrors: []string{
"Forbidden::test-nodes.spec.machineType",
},
},
{
Input: kops.InstanceGroupSpec{
SpotDurationInMinutes: fi.Int64(55),