This is an automated email from the ASF dual-hosted git repository.

vincbeck pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 1d63c9cbedb Exclude minimal and ECS Amazon Linux AMIs in 
get_latest_ami_id (#75171)
1d63c9cbedb is described below

commit 1d63c9cbedb90c96ac9aa1c515febd88f9b40a29
Author: Niko Oliveira <[email protected]>
AuthorDate: Tue Oct 20 05:01:20 2026 -0700

    Exclude minimal and ECS Amazon Linux AMIs in get_latest_ami_id (#75171)
    
    The loose description filter let *-minimal-* variants win on CreationDate.
    Those carry a 2 GiB root volume and no preinstalled amazon-ssm-agent, so
    example_ssm intermittently failed with "No space left on device" once its
    user-data script installed the agent.
    
    Excluding the minimal and ECS-optimized variants alongside the existing
    preview exclusion leaves only the standard 8 GiB images.
---
 .../amazon/tests/system/amazon/aws/utils/ec2.py    | 29 ++++++++++++++--------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/providers/amazon/tests/system/amazon/aws/utils/ec2.py 
b/providers/amazon/tests/system/amazon/aws/utils/ec2.py
index c162df118b8..a04c0a25cd1 100644
--- a/providers/amazon/tests/system/amazon/aws/utils/ec2.py
+++ b/providers/amazon/tests/system/amazon/aws/utils/ec2.py
@@ -60,11 +60,20 @@ def get_latest_ami_id():
 
     # Amazon Linux images are published with a description such as
     # "Amazon Linux 2023 AMI 2023.9.20260819.0 arm64 HVM kernel-6.1", so this 
prefix matches every
-    # generation without needing an update when a new one is released. It also 
matches the preview
-    # images of unreleased generations, which are filtered out below.
+    # generation without needing an update when a new one is released. 
Unsuitable variants are
+    # filtered out below.
     image_prefix = "Amazon Linux*"
     root_device_name = "/dev/xvda"
 
+    # Variants which must not be selected, matched against the image name and 
description.
+    #   preview: images of an unreleased Amazon Linux generation are always 
newer than the latest
+    #            released one, and are not supported by every AWS service.
+    #   minimal: these carry a 2 GiB root volume and do not preinstall 
amazon-ssm-agent, leaving
+    #            no headroom for tests that install packages (see 
example_ssm.py).
+    #   ecs:     the ECS-optimized variants carry a 30 GiB root volume and 
extra preinstalled
+    #            software that these tests do not need.
+    excluded_variants = ("preview", "minimal", "ecs")
+
     images = boto3.client("ec2").describe_images(
         Filters=[
             {"Name": "description", "Values": [image_prefix]},
@@ -81,19 +90,19 @@ def get_latest_ami_id():
         Owners=["amazon"],
     )
 
-    # Preview images of an unreleased Amazon Linux generation are always newer 
than the latest released
-    # one, and they are not supported by every AWS service, so they must not 
be picked here. describe_images
-    # filters cannot express "does not contain", hence the filtering below.
-    released_images = [
+    suitable_images = [
         image
         for image in images["Images"]
-        if "preview" not in f"{image.get('Name', '')} 
{image.get('Description', '')}".lower()
+        if not any(
+            variant in f"{image.get('Name', '')} {image.get('Description', 
'')}".lower()
+            for variant in excluded_variants
+        )
     ]
-    if not released_images:
-        raise ValueError("No released Amazon Linux AMI matching the requested 
criteria was found.")
+    if not suitable_images:
+        raise ValueError("No suitable Amazon Linux AMI matching the requested 
criteria was found.")
 
     # Sort on CreationDate
-    return max(released_images, key=itemgetter("CreationDate"))["ImageId"]
+    return max(suitable_images, key=itemgetter("CreationDate"))["ImageId"]
 
 
 @task

Reply via email to