From 2dee58d74909fbbdb166581fedac1f4531464e25 Mon Sep 17 00:00:00 2001 From: Josh Siviour Date: Mon, 21 Sep 2026 10:12:45 +1000 Subject: [PATCH] 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. --- spinifex/handlers/ec2/instance/service_impl.go | 2 +- spinifex/handlers/ec2/instance/service_impl_test.go | 4 ++-- spinifex/handlers/ecs/capacity.go | 3 ++- spinifex/handlers/eks/nodegroup.go | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spinifex/handlers/ec2/instance/service_impl.go b/spinifex/handlers/ec2/instance/service_impl.go index ce609cc16..4ad7e0ea2 100644 --- a/spinifex/handlers/ec2/instance/service_impl.go +++ b/spinifex/handlers/ec2/instance/service_impl.go @@ -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 } diff --git a/spinifex/handlers/ec2/instance/service_impl_test.go b/spinifex/handlers/ec2/instance/service_impl_test.go index 84e934291..a845ce5b4 100644 --- a/spinifex/handlers/ec2/instance/service_impl_test.go +++ b/spinifex/handlers/ec2/instance/service_impl_test.go @@ -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") diff --git a/spinifex/handlers/ecs/capacity.go b/spinifex/handlers/ecs/capacity.go index 124f6f6b7..b49048e44 100644 --- a/spinifex/handlers/ecs/capacity.go +++ b/spinifex/handlers/ecs/capacity.go @@ -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{{ diff --git a/spinifex/handlers/eks/nodegroup.go b/spinifex/handlers/eks/nodegroup.go index 9b0033f34..9b83bc11e 100644 --- a/spinifex/handlers/eks/nodegroup.go +++ b/spinifex/handlers/eks/nodegroup.go @@ -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)}, }} }