fix: default the root block device to the name the AMI declares (#1095)

RunInstances defaulted the root device to /dev/vda, the path the guest sees, so an instance launched without a block device mapping reported a DeviceName that contradicted its own RootDeviceName of /dev/sda1.

ECS capacity and EKS nodegroups named the same guest path explicitly, so every internally launched instance carried it too. All three now name ebsmetadata.RootDeviceName, which is what AWS returns and what the guest already resolves through its own device links.
This commit is contained in:
Josh Siviour
2026-09-21 10:12:45 +10:00
committed by GitHub
parent b53ac2d148
commit 2dee58d749
4 changed files with 7 additions and 5 deletions
@@ -177,7 +177,7 @@ func UnservedBlockDeviceMappings(mappings []*ec2.BlockDeviceMapping) []string {
func parseVolumeParams(input *ec2.RunInstancesInput) volumeParams {
p := volumeParams{
size: 4 * 1024 * 1024 * 1024, // 4GB default
deviceName: "/dev/vda",
deviceName: ebsmetadata.RootDeviceName,
deleteOnTermination: true, // matches AWS RunInstances behavior
}
@@ -376,7 +376,7 @@ func TestParseVolumeParams_Defaults(t *testing.T) {
p := parseVolumeParams(input)
assert.Equal(t, 4*1024*1024*1024, p.size, "default size should be 4GB")
assert.Equal(t, "/dev/vda", p.deviceName, "default device should be /dev/vda")
assert.Equal(t, ebsmetadata.RootDeviceName, p.deviceName, "default device should be the name the AMI declares")
assert.True(t, p.deleteOnTermination, "deleteOnTermination should default to true")
assert.Empty(t, p.volumeType)
assert.Zero(t, p.iops)
@@ -454,7 +454,7 @@ func TestParseVolumeParams_PartialEbs(t *testing.T) {
p := parseVolumeParams(input)
assert.Equal(t, 8*1024*1024*1024, p.size)
assert.Equal(t, "/dev/vda", p.deviceName, "device should stay at default")
assert.Equal(t, ebsmetadata.RootDeviceName, p.deviceName, "device should stay at default")
assert.Empty(t, p.volumeType, "volumeType should stay empty")
assert.Zero(t, p.iops, "iops should stay zero")
assert.True(t, p.deleteOnTermination, "deleteOnTermination should stay at default")
+2 -1
View File
@@ -9,6 +9,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/mulgadc/spinifex/spinifex/awserrors"
"github.com/mulgadc/spinifex/spinifex/ebsmetadata"
"github.com/mulgadc/spinifex/spinifex/instancetypes"
"github.com/mulgadc/spinifex/spinifex/tags"
"github.com/mulgadc/spinifex/spinifex/utils"
@@ -132,7 +133,7 @@ func (s *Service) ProvisionCapacity(ctx context.Context, input *ProvisionCapacit
UserData: aws.String(userData),
IamInstanceProfile: &ec2.IamInstanceProfileSpecification{Arn: aws.String(profileARN)},
BlockDeviceMappings: []*ec2.BlockDeviceMapping{{
DeviceName: aws.String("/dev/vda"),
DeviceName: aws.String(ebsmetadata.RootDeviceName),
Ebs: &ec2.EbsBlockDevice{VolumeSize: aws.Int64(diskSize)},
}},
TagSpecifications: []*ec2.TagSpecification{{
+2 -1
View File
@@ -23,6 +23,7 @@ import (
"github.com/mulgadc/bluebottle/pkg/auth"
"github.com/mulgadc/spinifex/spinifex/arn"
"github.com/mulgadc/spinifex/spinifex/awserrors"
"github.com/mulgadc/spinifex/spinifex/ebsmetadata"
handlers_iam "github.com/mulgadc/spinifex/spinifex/handlers/iam"
"github.com/mulgadc/spinifex/spinifex/instancetypes"
"github.com/nats-io/nats.go/jetstream"
@@ -664,7 +665,7 @@ func (s *EKSServiceImpl) launchOneWorker(ctx context.Context, rec *NodegroupReco
}
if rec.DiskSize > 0 {
runInput.BlockDeviceMappings = []*ec2.BlockDeviceMapping{{
DeviceName: aws.String("/dev/vda"),
DeviceName: aws.String(ebsmetadata.RootDeviceName),
Ebs: &ec2.EbsBlockDevice{VolumeSize: aws.Int64(rec.DiskSize)},
}}
}