Skip to content

Commit

Permalink
Merge pull request #6969 from cPu1/iso-gp3-volume
Browse files Browse the repository at this point in the history
Switch default volume type back to gp3 for ISO regions
  • Loading branch information
cPu1 authored Aug 21, 2023
2 parents 03cffdd + 8952ed0 commit 4fa8da6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 51 deletions.
20 changes: 10 additions & 10 deletions pkg/apis/eksctl.io/v1alpha5/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ func SetNodeGroupDefaults(ng *NodeGroup, meta *ClusterMeta, controlPlaneOnOutpos
ng.AMIFamily = DefaultNodeImageFamily
}

setVolumeDefaults(ng.NodeGroupBase, controlPlaneOnOutposts, meta.Region, nil)
setDefaultsForAdditionalVolumes(ng.NodeGroupBase, controlPlaneOnOutposts, meta.Region)
setVolumeDefaults(ng.NodeGroupBase, controlPlaneOnOutposts, nil)
setDefaultsForAdditionalVolumes(ng.NodeGroupBase, controlPlaneOnOutposts)

if ng.SecurityGroups.WithLocal == nil {
ng.SecurityGroups.WithLocal = Enabled()
Expand Down Expand Up @@ -134,8 +134,8 @@ func SetManagedNodeGroupDefaults(ng *ManagedNodeGroup, meta *ClusterMeta, contro
ng.Tags[NodeGroupNameTag] = ng.Name
ng.Tags[NodeGroupTypeTag] = string(NodeGroupTypeManaged)

setVolumeDefaults(ng.NodeGroupBase, controlPlaneOnOutposts, meta.Region, ng.LaunchTemplate)
setDefaultsForAdditionalVolumes(ng.NodeGroupBase, controlPlaneOnOutposts, meta.Region)
setVolumeDefaults(ng.NodeGroupBase, controlPlaneOnOutposts, ng.LaunchTemplate)
setDefaultsForAdditionalVolumes(ng.NodeGroupBase, controlPlaneOnOutposts)
}

func setNodeGroupBaseDefaults(ng *NodeGroupBase, meta *ClusterMeta) {
Expand Down Expand Up @@ -178,9 +178,9 @@ func setNodeGroupBaseDefaults(ng *NodeGroupBase, meta *ClusterMeta) {
}
}

func setVolumeDefaults(ng *NodeGroupBase, controlPlaneOnOutposts bool, region string, template *LaunchTemplate) {
func setVolumeDefaults(ng *NodeGroupBase, controlPlaneOnOutposts bool, template *LaunchTemplate) {
if ng.VolumeType == nil {
ng.VolumeType = aws.String(getDefaultVolumeType(controlPlaneOnOutposts || ng.OutpostARN != "", region))
ng.VolumeType = aws.String(getDefaultVolumeType(controlPlaneOnOutposts || ng.OutpostARN != ""))
}
if ng.VolumeSize == nil && template == nil {
ng.VolumeSize = &DefaultNodeVolumeSize
Expand All @@ -206,10 +206,10 @@ func setVolumeDefaults(ng *NodeGroupBase, controlPlaneOnOutposts bool, region st
}
}

func setDefaultsForAdditionalVolumes(ng *NodeGroupBase, controlPlaneOnOutposts bool, region string) {
func setDefaultsForAdditionalVolumes(ng *NodeGroupBase, controlPlaneOnOutposts bool) {
for i, av := range ng.AdditionalVolumes {
if av.VolumeType == nil {
ng.AdditionalVolumes[i].VolumeType = aws.String(getDefaultVolumeType(controlPlaneOnOutposts, region))
ng.AdditionalVolumes[i].VolumeType = aws.String(getDefaultVolumeType(controlPlaneOnOutposts))
}
if av.VolumeSize == nil {
ng.AdditionalVolumes[i].VolumeSize = &DefaultNodeVolumeSize
Expand All @@ -228,11 +228,11 @@ func setDefaultsForAdditionalVolumes(ng *NodeGroupBase, controlPlaneOnOutposts b
}
}

func getDefaultVolumeType(nodeGroupOnOutposts bool, region string) string {
func getDefaultVolumeType(nodeGroupOnOutposts bool) string {
if nodeGroupOnOutposts {
return NodeVolumeTypeGP2
}
return defaultVolumeTypeForRegion(region)
return DefaultNodeVolumeType
}

func setContainerRuntimeDefault(ng *NodeGroup, clusterVersion string) {
Expand Down
29 changes: 0 additions & 29 deletions pkg/apis/eksctl.io/v1alpha5/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,35 +192,6 @@ var _ = Describe("ClusterConfig validation", func() {
Expect(*testNodeGroup.AdditionalVolumes[0].VolumeType).To(Equal(NodeVolumeTypeGP2))
Expect(*testNodeGroup.AdditionalVolumes[0].VolumeSize).To(Equal(DefaultNodeVolumeSize))
})

It("sets up defaults for the main volume in an ISO region", func() {
testNodeGroup := NodeGroup{
NodeGroupBase: &NodeGroupBase{},
}

SetNodeGroupDefaults(&testNodeGroup, &ClusterMeta{
Region: RegionUSISOEast1,
}, false)
Expect(*testNodeGroup.VolumeType).To(Equal(NodeVolumeTypeIO1))
Expect(*testNodeGroup.VolumeSize).To(Equal(DefaultNodeVolumeSize))
})
It("sets up defaults for any additional volume in an ISO region", func() {
testNodeGroup := NodeGroup{
NodeGroupBase: &NodeGroupBase{
AdditionalVolumes: []*VolumeMapping{
{
VolumeName: aws.String("test"),
},
},
},
}

SetNodeGroupDefaults(&testNodeGroup, &ClusterMeta{
Region: RegionUSISOBEast1,
}, false)
Expect(*testNodeGroup.AdditionalVolumes[0].VolumeType).To(Equal(NodeVolumeTypeIO1))
Expect(*testNodeGroup.AdditionalVolumes[0].VolumeSize).To(Equal(DefaultNodeVolumeSize))
})
})

Context("Bottlerocket Settings", func() {
Expand Down
9 changes: 0 additions & 9 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,6 @@ const (
DefaultRegion = RegionUSWest2
)

func defaultVolumeTypeForRegion(region string) string {
switch region {
case RegionUSISOEast1, RegionUSISOBEast1:
return NodeVolumeTypeIO1
default:
return DefaultNodeVolumeType
}
}

// Values for `NodeAMIFamily`
// All valid values of supported families should go in this block
const (
Expand Down
3 changes: 0 additions & 3 deletions pkg/ctl/cmdutils/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,6 @@ func normalizeBaseNodeGroup(np api.NodePool, cmd *cobra.Command) {
if !flags.Changed("enable-ssm") {
ng.SSH.EnableSSM = nil
}
if !flags.Changed("node-volume-type") {
ng.VolumeType = nil
}
}

// NewDeleteAndDrainNodeGroupLoader will load config or use flags for 'eksctl delete nodegroup'
Expand Down

0 comments on commit 4fa8da6

Please sign in to comment.