From 5648be79c46b6f9fd79f3b1191cc7e045ade0cf6 Mon Sep 17 00:00:00 2001 From: Sam Fakhreddine Date: Mon, 14 Sep 2026 07:58:45 -0600 Subject: [PATCH] fix(ec2): let dnf swap curl-minimal for curl when installing the IMDS proxy (#3284) public.ecr.aws/amazonlinux/amazonlinux:2023, the fallback image AmiImageResolver uses for any unrecognized AMI ID, ships curl-minimal by default. metadataProxyInstallCommand()'s dnf branch asked for the full curl package alongside iproute and socat; curl and curl-minimal both provide /usr/bin/curl and can't coexist, so dnf aborted the whole transaction on that conflict. iproute and socat never installed either, even though neither of them conflicts with anything. The failure was only ever logged as a WARN by Ec2ContainerManager and the instance still reported running, so a caller had no signal the link-local IMDS endpoint was dead. Reproduced against the real image: dnf reported dozens of "package curl-minimal-... conflicts with curl provided by curl-..." lines for every curl-minimal version in the repo. --allowerasing lets dnf swap curl-minimal for curl instead of aborting. Closes floci-io/floci#3281 --- .../floci/services/ec2/Ec2ContainerManager.java | 7 ++++++- .../services/ec2/Ec2ContainerManagerTest.java | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManager.java b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManager.java index 68800d1d1f..a96159925d 100644 --- a/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManager.java +++ b/src/main/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManager.java @@ -1633,7 +1633,12 @@ public class Ec2ContainerManager { " apt-get update -qq >/dev/null", " DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends iproute2 socat curl ca-certificates >/dev/null", "elif command -v dnf >/dev/null 2>&1; then", - " dnf install -y iproute socat curl ca-certificates >/dev/null", + // --allowerasing lets dnf swap the curl-minimal that + // public.ecr.aws/amazonlinux/amazonlinux:2023 ships by default for the full + // curl package this proxy needs. Without it, dnf aborts the whole transaction + // on a curl/curl-minimal conflict and iproute+socat never install either, even + // though neither of them conflicts with anything. + " dnf install -y --allowerasing iproute socat curl ca-certificates >/dev/null", // Same gap as the sshd probe: Amazon Linux 2 has only yum, so on an instance // launched from ami-amazonlinux2 this chain reached its else branch and exited 1 // with "No supported package manager found for IMDS proxy dependencies" -- diff --git a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManagerTest.java b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManagerTest.java index 17daa0bd54..8a6fa051df 100644 --- a/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManagerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/ec2/Ec2ContainerManagerTest.java @@ -796,6 +796,22 @@ class Ec2ContainerManagerTest { assertTrue(script.contains("yum install -y iproute socat curl ca-certificates"), script); } + @Test + void metadataProxyInstallCommandLetsDnfReplaceCurlMinimalWithCurl() { + // public.ecr.aws/amazonlinux/amazonlinux:2023 -- the fallback image AmiImageResolver + // uses for any unrecognized AMI ID -- ships curl-minimal by default. Without + // --allowerasing, "dnf install -y iproute socat curl ca-certificates" fails the whole + // transaction on a curl/curl-minimal conflict (they both provide /usr/bin/curl), so + // iproute and socat never install either, even though neither of them conflicts with + // anything. Reproduced against the real image: dnf reported dozens of + // "package curl-minimal-... conflicts with curl provided by curl-..." lines and the + // instance was left with no link-local IMDS endpoint. + String script = Ec2ContainerManager.metadataProxyInstallCommand()[2]; + + assertTrue(script.contains("dnf install -y --allowerasing iproute socat curl ca-certificates"), + script); + } + @Test void metadataProxyStartCommandBindsAwsLinkLocalMetadataAddress() { String[] command = Ec2ContainerManager.metadataProxyStartCommand("floci", 9169);