Skip to content
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

Validate IG RootVolumeType #9265

Merged
merged 2 commits into from Jun 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/apis/kops/validation/instancegroup.go
Expand Up @@ -209,6 +209,10 @@ func CrossValidateInstanceGroup(g *kops.InstanceGroup, cluster *kops.Cluster) fi
}
}

if g.Spec.RootVolumeType != nil && kops.CloudProviderID(cluster.Spec.CloudProvider) == kops.CloudProviderAWS {
allErrs = append(allErrs, IsValidValue(field.NewPath("spec", "rootVolumeType"), g.Spec.RootVolumeType, []string{"gp2", "io1"})...)
}

return allErrs
}

Expand Down
42 changes: 42 additions & 0 deletions pkg/apis/kops/validation/instancegroup_test.go
Expand Up @@ -179,3 +179,45 @@ func TestValidMasterInstanceGroup(t *testing.T) {
}

}

func TestValidBootDevice(t *testing.T) {

cluster := &kops.Cluster{
Spec: kops.ClusterSpec{
CloudProvider: "aws",
},
}
grid := []struct {
volumeType string
expected []string
}{
{
volumeType: "gp2",
},
{
volumeType: "io1",
},
{
volumeType: "st1",
expected: []string{"Unsupported value::spec.rootVolumeType"},
},
{
volumeType: "sc1",
expected: []string{"Unsupported value::spec.rootVolumeType"},
},
}

for _, g := range grid {
ig := &kops.InstanceGroup{
ObjectMeta: v1.ObjectMeta{
Name: "some-ig",
},
Spec: kops.InstanceGroupSpec{
Role: "Node",
RootVolumeType: fi.String(g.volumeType),
},
}
errs := CrossValidateInstanceGroup(ig, cluster)
testErrors(t, g.volumeType, errs, g.expected)
}
}