Skip to content
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

Add tag while uploading rhcos images #35

Conversation

ashwini3326
Copy link

This merge request enables adding tags to images being uploaded to aws and azure. @JAVGan @jajreidy @rohanpm PTAL.

@lslebodn
Copy link

Have you considered to use tag_s3_object similar as we do in upload_to_container ?

cloudimg/cloudimg/aws.py

Lines 539 to 540 in b416dc0

if tags:
self.tag_s3_object(container_name, object_name, tags)

or similar for azure?
https://github.com/release-engineering/cloudimg/blob/b416dc055d98d2e08e3dd4c77e2deb2d658fe8d4/cloudimg/ms_azure.py#L612C9-L612C18

"""
Create copy of an AMI.

Args:
image_id (str): AMI Id of the image to copy
name (str): Name of new image
region(str): Region for new Image.
tags(list, optional): Tags to be associated with new ami.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's documented as optional, but it's not actually optional in the python sense - copy_ami now requires a value for tags, and 100% of existing callers won't be providing that, so they'll just crash. This is a severe backwards-incompatible change.

It needs to be made genuinely optional.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment still seems to be valid: if someone calls this method without providing tags, it'll crash, so it's still not backwards-compatible.

What I'm saying is that the signature should have:

tags=None

@@ -365,10 +365,20 @@ def test_copy_ami(self):
self.mock_copy_ami.return_value = {
'ImageId': 'ami-08',
'ResponseMetadata': {'RequestId': 'cf32', 'server': 'AmazonEC2'}}
copy_ami_result = self.svc.copy_ami("ami-01", "rhcos", "us-east-1")
self.assertEqual(copy_ami_result['ImageId'], "ami-08")
copy_ami_result = self.svc.copy_ami(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: rather than changing the only test which calls copy_ami so that it passes the new argument, it would be nice to instead add a new call so that there is coverage of both passing and not passing tags.

This relates to my earlier comment about the argument wrongly not being optional. That'll cause existing callers of copy_ami to crash. The test not passing tags accurately reproduces what any existing caller of copy_ami was doing, so the test would have been able to catch this crash.

Changing the test so it always passes tags means there is no longer any test which reproduces what the current users of copy_ami are doing, hiding a potential source of crash that real users would encounter.

Copy link
Author

@ashwini3326 ashwini3326 May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes it to support cases with tags as None. PTAL

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rohanpm PTAL

@ashwini3326
Copy link
Author

As this issue is fixed by another merge reqest to pubtools-marketplacesvm , it is not required now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants