-
Notifications
You must be signed in to change notification settings - Fork 17
AWS: Ensure "snapshot_tags" is present on AMIs #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
AWS: Ensure "snapshot_tags" is present on AMIs #43
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 615 +29
==========================================
+ Hits 571 591 +20
- Misses 15 24 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
rbikar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, @JAVGan only a little question, the "snapshot_tags" is kind of hardcoded here. Is it something required by aws API or rather is it required minimum for tags set on image/snapshot?
cloudimg/aws.py
Outdated
| self.get_image_by_tags( | ||
| metadata.tags, | ||
| required_tags=["snapshot_tags"], | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 :-) )
Line 618 in 641e5bf
add_tags("tags", extra_kwargs) Line 618 in 641e5bf
add_tags("tags", extra_kwargs)
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 ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TY
|
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>
This commit adds more debug logs for the filtering of images and snapshots on AWSService. Signed-off-by: Jonathan Gangi <jgangi@redhat.com>
7fc2c9e to
f19a3bd
Compare
lslebodn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@rbikar please re-review
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