mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-20 11:21:49 +00:00
fix(eks): propagate nodegroup DiskSize to worker root volume
launchWorkers built RunInstancesInput with no BlockDeviceMappings, so parseVolumeParams applied the 4GB root-volume default and the nodegroup DiskSize was silently ignored. Wire rec.DiskSize into a BlockDeviceMapping when set.
This commit is contained in:
@@ -327,6 +327,12 @@ func (s *EKSServiceImpl) launchWorkers(accountID string, rec *NodegroupRecord, m
|
||||
},
|
||||
}},
|
||||
}
|
||||
if rec.DiskSize > 0 {
|
||||
runInput.BlockDeviceMappings = []*ec2.BlockDeviceMapping{{
|
||||
DeviceName: aws.String("/dev/vda"),
|
||||
Ebs: &ec2.EbsBlockDevice{VolumeSize: aws.Int64(rec.DiskSize)},
|
||||
}}
|
||||
}
|
||||
res, err := s.deps.Worker.RunWorkerInstance(runInput, accountID)
|
||||
if err != nil {
|
||||
return ids, fmt.Errorf("run worker %d/%d: %w", i+1, count, err)
|
||||
|
||||
@@ -213,6 +213,34 @@ func TestCreateNodegroup_HappyPath(t *testing.T) {
|
||||
require.EqualError(t, err, awserrors.ErrorEKSResourceInUse)
|
||||
}
|
||||
|
||||
func TestCreateNodegroup_DiskSizePropagatesToBlockDeviceMapping(t *testing.T) {
|
||||
f := newEKSServiceFixture(t)
|
||||
seedActiveClusterWithToken(t, f, "c1")
|
||||
|
||||
in := createNGInput("c1", "ng1", 1)
|
||||
in.DiskSize = aws.Int64(30)
|
||||
_, err := f.svc.CreateNodegroup(in, testAccountID)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, f.worker.runCalls, 1)
|
||||
bdm := f.worker.runCalls[0].BlockDeviceMappings
|
||||
require.Len(t, bdm, 1)
|
||||
require.NotNil(t, bdm[0].Ebs)
|
||||
assert.Equal(t, int64(30), aws.Int64Value(bdm[0].Ebs.VolumeSize))
|
||||
}
|
||||
|
||||
func TestCreateNodegroup_NoDiskSizeOmitsBlockDeviceMapping(t *testing.T) {
|
||||
f := newEKSServiceFixture(t)
|
||||
seedActiveClusterWithToken(t, f, "c1")
|
||||
|
||||
_, err := f.svc.CreateNodegroup(createNGInput("c1", "ng1", 1), testAccountID)
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, f.worker.runCalls, 1)
|
||||
// No DiskSize requested → leave the launch path on its default sizing.
|
||||
assert.Empty(t, f.worker.runCalls[0].BlockDeviceMappings)
|
||||
}
|
||||
|
||||
func TestCreateNodegroup_ClusterNotActive(t *testing.T) {
|
||||
f := newEKSServiceFixture(t)
|
||||
require.NoError(t, PutClusterMeta(f.kv, &ClusterMeta{
|
||||
|
||||
Reference in New Issue
Block a user