AWS: Ensure "snapshot_tags" is present on AMIs#43
AWS: Ensure "snapshot_tags" is present on AMIs#43rbikar merged 2 commits intorelease-engineering:masterfrom
Conversation
8413c6f to
59fa787
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #43 +/- ##
==========================================
- Coverage 97.44% 96.09% -1.35%
==========================================
Files 3 3
Lines 586 614 +28
==========================================
+ Hits 571 590 +19
- Misses 15 24 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cloudimg/aws.py
Outdated
| self.get_image_by_tags( | ||
| metadata.tags, | ||
| required_tags=["snapshot_tags"], | ||
| ) |
There was a problem hiding this comment.
There are couple of tag parameters passed to he publish method via metada from the pubtools-marketplacesvm.
tags
- https://github.com/release-engineering/pubtools-marketplacesvm/blob/eb063b4890b9e2cf72f7c2308a9d1f55ebfb6e8c/src/pubtools/_marketplacesvm/cloud_providers/aws.py#L434
which are detected from image metadata - https://github.com/release-engineering/pubtools-marketplacesvm/blob/eb063b4890b9e2cf72f7c2308a9d1f55ebfb6e8c/src/pubtools/_marketplacesvm/cloud_providers/aws.py#L434
They are automatically extended by "custom_tags" provided by user via starmap-mappings.
ami_tags&&snapshot_tagspassed here
So far they are the same and just contain billing code
Different objects should be find by following tags:
- s3 object should be bound by
tags - snapshot should by find by union of
tagsandsnapshot_tags - ami should by find by union of
tagsandami_tags
We tried to merge tags via add_tags local function for snapshot
(BTW when I return back to the code; it always take me a minute to understand how add_tags works :-) )
But it was not done for for ami_tags.
So I would say get_image_by_tags needn't have new parameter. We should just pass right values there via current parameter tags
Anyway, It would be nice to improve logging a bit. We automatically fallback to finding image by tags if it cannot be find by name. But it is impossible to identify from logs.
It will be much simpler to analyze issue when one could see a message.
DEBUG ... Cannot find ami by name {metadata.image_name}. Going to try by tags ...
|
Cloudimg support python3.6+
Python3.9 introduced simple way of creating a new dictionary with the merged keys ( It would allow "oneliner" fix
One would just need to ensure both are dict (none None) |
59fa787 to
93cb2fd
Compare
|
@lslebodn I've changed this PR so instead of using a new parameter for Since this is not using Python3.9 exclusively I've opted out for a solution which is widely compatible instead of the operator I'll add a new commit on top of it to improve the logs. @rbikar FYI |
|
@lslebodn PTAL again |
f74d17b to
7fc2c9e
Compare
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 <jgangi@redhat.com>
7fc2c9e to
f19a3bd
Compare
|
@rbikar if it looks good to you feel free to merge & release as well |
cloudimg/aws.py
Outdated
This commit adds more debug logs for the filtering of images and snapshots on AWSService. Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
f19a3bd to
a042462
Compare
This commit changes the
get_image_by_tagscall onpublishmethod forAWSServiceso it will search for the snapshot tags alonside therequested 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