fix(autoscaling): launch with the launch configuration's block devices (#7098)

* fix(autoscaling): launch with the launch configuration's block devices

Auto Scaling groups launching from a launch configuration passed none
of its block device mappings to the launch, so their instances got the
AMI's devices alone. They now pass them, with the configuration's
Boolean NoDevice converted to EC2's marker, and instance refresh
replacements get them too. A mapping the launch refuses, such as an
invalid device name, now fails the launch as a failed scaling activity.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* test(ec2): count volume store scans for a DescribeInstances response

The test for one volume read per DescribeInstances response counted
calls to instanceVolumeAttachments, so a scan moved inside that
helper's instance loop still passed it. It now counts scans of the
volume store for a three-instance response, which fail with three
scans both before the fix and with that loop.

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>

* fix(autoscaling): default launch configuration volumes to delete on termination

* test: share signed Query requests for launch block devices

---------

Signed-off-by: Jackson Price <59149601+jprice8@users.noreply.github.com>
This commit is contained in:
Jackson Price authored and GitHub committed 2026-10-31 15:00:18 -04:00
1 parent 2eb75ee686
commit dbb1ff6d89
8 files changed
+319 -25

No files matched your search

@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.autoscaling.model.InstanceRefresh;
import io.github.hectorvent.floci.services.autoscaling.model.InstanceRefreshLaunch;
import io.github.hectorvent.floci.services.autoscaling.model.InstanceRefreshReplacement;
import io.github.hectorvent.floci.services.autoscaling.model.LaunchConfiguration;
import io.github.hectorvent.floci.services.autoscaling.model.LaunchConfigurationBlockDeviceMapping;
import io.github.hectorvent.floci.services.autoscaling.model.MixedInstancesPolicy;
import io.github.hectorvent.floci.services.autoscaling.model.ScalingActivity;
import io.github.hectorvent.floci.services.ec2.Ec2Service;
@@ -943,7 +944,7 @@ public class AutoScalingReconciler {
// subnet's MapPublicIpOnLaunch, and only null means
// "fall back to the subnet default".
lc.getAssociatePublicIpAddress(),
null, lc.getMetadataOptions(), null);
launchConfigurationBlockDevices(lc), lc.getMetadataOptions(), null);
}
LaunchTemplate launchTemplate = resolveLaunchTemplate(asg);
@@ -1016,6 +1017,38 @@ public class AutoScalingReconciler {
return null;
}
/**
* A launch configuration's block device mappings in the shape RunInstances takes. Auto Scaling
* marks a suppressed device with a Boolean {@code NoDevice}, EC2 with an empty string.
*/
private static List<LaunchTemplateData.BlockDeviceMapping> launchConfigurationBlockDevices(
LaunchConfiguration configuration) {
List<LaunchTemplateData.BlockDeviceMapping> mappings = new ArrayList<>();
if (configuration.getBlockDeviceMappings() == null) {
return mappings;
}
for (LaunchConfigurationBlockDeviceMapping source : configuration.getBlockDeviceMappings()) {
LaunchTemplateData.BlockDeviceMapping mapping = new LaunchTemplateData.BlockDeviceMapping();
mapping.setDeviceName(source.getDeviceName());
mapping.setVirtualName(source.getVirtualName());
mapping.setNoDevice(Boolean.TRUE.equals(source.getNoDevice()) ? "" : null);
LaunchConfigurationBlockDeviceMapping.Ebs sourceEbs = source.getEbs();
if (sourceEbs != null) {
LaunchTemplateData.Ebs ebs = new LaunchTemplateData.Ebs();
ebs.setSnapshotId(sourceEbs.getSnapshotId());
ebs.setVolumeSize(sourceEbs.getVolumeSize());
ebs.setVolumeType(sourceEbs.getVolumeType());
ebs.setDeleteOnTermination(!Boolean.FALSE.equals(sourceEbs.getDeleteOnTermination()));
ebs.setIops(sourceEbs.getIops());
ebs.setThroughput(sourceEbs.getThroughput());
ebs.setEncrypted(sourceEbs.getEncrypted());
mapping.setEbs(ebs);
}
mappings.add(mapping);
}
return mappings;
}
private static String encodeLegacyUserData(String userData) {
return userData == null ? null : Base64.getEncoder().encodeToString(userData.getBytes(StandardCharsets.UTF_8));
}
@@ -5,8 +5,8 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
/**
* One entry of a launch configuration's {@code BlockDeviceMappings}. The shape follows the
* Auto Scaling API rather than EC2's, which has no {@code Throughput}, {@code Iops},
* {@code VirtualName} or {@code NoDevice} on its launch-time mapping.
* Auto Scaling API rather than EC2's: {@code NoDevice} is a Boolean here, where EC2's launch-time
* mapping marks a suppressed device with a string.
*/
@RegisterForReflection
@JsonIgnoreProperties(ignoreUnknown = true)