From b88930221e08a1ca23c559921898652aded8a6d6 Mon Sep 17 00:00:00 2001 From: Jonathan Gangi Date: Wed, 21 Jan 2026 15:31:55 -0300 Subject: [PATCH 1/2] AWS: Ensure "snapshot_tags" is present on AMIs This commit changes the `get_image_by_tags` call on `publish` method for `AWSService` so it will search for the snapshot tags alonside the requested tags. We need that to ensure the snapshot was properly created in order to avoid retrieving the wrong AMI during the search. Refers to SPSTRAT-615 Signed-off-by: Jonathan Gangi --- cloudimg/aws.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cloudimg/aws.py b/cloudimg/aws.py index d8db352..f4b4c91 100644 --- a/cloudimg/aws.py +++ b/cloudimg/aws.py @@ -595,9 +595,13 @@ def add_tags(tag_parameter_name, extra_kwargs): extra_kwargs.update({"tags": new_tags}) log.info('Searching for image: %s', metadata.image_name) + merged_ami_tags = { + **(metadata.tags or {}), + **(metadata.ami_tags or {}), + } image = ( self.get_image_by_name(metadata.image_name) or - self.get_image_by_tags(metadata.tags) + self.get_image_by_tags(merged_ami_tags) ) if not image: From f19a3bd03458f3b9d1eee83b481241c6632506e6 Mon Sep 17 00:00:00 2001 From: Jonathan Gangi Date: Thu, 22 Jan 2026 10:14:07 -0300 Subject: [PATCH 2/2] AWS: Improve logs for filtering image/snapshot This commit adds more debug logs for the filtering of images and snapshots on AWSService. Signed-off-by: Jonathan Gangi --- cloudimg/aws.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cloudimg/aws.py b/cloudimg/aws.py index f4b4c91..2a06cd5 100644 --- a/cloudimg/aws.py +++ b/cloudimg/aws.py @@ -244,6 +244,7 @@ def get_image_by_filters(self, filters): images = rsp['Images'] if not images: + log.debug("No images returned for the filters %s", filters) return None elif len(images) > 1: amis = [x['ImageId'] for x in images] @@ -276,6 +277,7 @@ def get_image_from_ami_catalog(self, image_id): images = rsp["Images"] if not images: + log.debug("No image with ID %s found.", image_id) return None return self.ec2.Image(images[0]["ImageId"]) @@ -291,6 +293,7 @@ def get_image_by_name(self, name): An EC2 Image if found; None otherwise """ if not name: + log.debug("Name not provided to search for the image.") return None filters = [ @@ -313,6 +316,7 @@ def get_image_by_tags(self, tags): An EC2 Image if found; None otherwise """ if not tags: + log.debug("Tags not provided to search for the image.") return None filters = [ @@ -336,6 +340,7 @@ def get_image_by_id(self, image_id): An EC2 Image if found; None otherwise """ if not image_id: + log.debug("Image ID not provided to search for the image.") return None filters = [ @@ -358,6 +363,7 @@ def get_snapshot_by_name(self, name): An EC2 Snapshot if found; None otherwise """ if not name: + log.debug("Name not provided to search for the snapshot.") return None rsp = self.ec2.meta.client.describe_snapshots( @@ -371,6 +377,7 @@ def get_snapshot_by_name(self, name): snapshots = rsp['Snapshots'] if not snapshots: + log.debug("No snapshot found with name %s.", name) return None elif len(snapshots) > 1: snaps = [x['SnapshotId'] for x in snapshots] @@ -392,6 +399,7 @@ def get_snapshot_by_id(self, snapshot_id): An EC2 Snapshot if found; None otherwise """ if not snapshot_id: + log.debug("ID not provided to search for the snapshot.") return None rsp = self.ec2.meta.client.describe_snapshots( @@ -405,6 +413,7 @@ def get_snapshot_by_id(self, snapshot_id): snapshots = rsp['Snapshots'] if not snapshots: + log.debug("No snapshot found with ID %s.", snapshot_id) return None return self.ec2.Snapshot(snapshots[0]['SnapshotId'])