Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

services.ec2: Delete the source for every image urls #112

Conversation

sayanchowdhury
Copy link
Contributor

Signed-off-by: Sayan Chowdhury [email protected]

@sayanchowdhury
Copy link
Contributor Author

@dustymabe Can you review this?

@@ -24,6 +24,8 @@

import re

from time import sleep

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't understand why this is removed. things in this file use it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was not removed, this was added.

Copy link
Contributor

Choose a reason for hiding this comment

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

oops. i guess my diff view confused me on that. Can you put this in a separate commit?

@@ -163,5 +163,8 @@ def main(image_urls, access_id, secret_key, regions, volume_types=None,
#TODO: Implement the clean up of the images if failed.
# uploader.clean_up(image_id=image.id, delete_snapshot=True)

shutil.rmtree(os.path.dirname(source))
if source:
Copy link
Contributor

Choose a reason for hiding this comment

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

in what cases does source evaluate to non true? I don't see what problem this is solving.

Copy link
Contributor Author

@sayanchowdhury sayanchowdhury Apr 25, 2018

Choose a reason for hiding this comment

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

There could be various reasons when source evaluates to non true, euca2ools does not setup, or wget fails. Though, fedimg raises ValueError if source is None but the handlers are not in place.

fedimg needs to be better at raising and catching exceptions. I started working on them this week and I have also opened up #113 for the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

it looks like this should be in a finally block then. If the valueError gets raised above then this code wouldn't get hit right?

@sayanchowdhury sayanchowdhury force-pushed the hotfix/105-remove-images-after-upload branch from 925f871 to bebd8bd Compare April 25, 2018 18:10
except Exception as e:
_log.debug(e.message)
return []
Copy link
Contributor

Choose a reason for hiding this comment

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

so here we are returning [] where we weren't sending anything back before. wehere is this main function getting called from?

Copy link
Contributor Author

@sayanchowdhury sayanchowdhury Apr 25, 2018

Choose a reason for hiding this comment

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

@@ -158,10 +158,16 @@ def main(image_urls, access_id, secret_key, regions, volume_types=None,
published_images.extend(publisher.publish_images(
region_image_mapping=[(region, image.id)]
))
except ValueError:
_log.debug('Source not found.')
return []
Copy link
Contributor

Choose a reason for hiding this comment

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

why not just do this on line 94 above where we raise the ValueError ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, my plan for raising exception is to remove anything that happened before. I'll just make changes according to your comments for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... Later when working on better exception handling, I'll look into it.

@sayanchowdhury sayanchowdhury force-pushed the hotfix/105-remove-images-after-upload branch from bebd8bd to b6379e4 Compare April 25, 2018 18:25
@@ -91,7 +91,8 @@ def main(image_urls, access_id, secret_key, regions, volume_types=None,
try:
source = get_source_from_image(image_url)
if not source:
raise ValueError
_log.debug('Source not found.')
return []
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks good for now but in the future I hope to get more output in the logs other than Source not found.. I opened #118 for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@dustymabe
Copy link
Contributor

LGTM

@sayanchowdhury sayanchowdhury force-pushed the hotfix/105-remove-images-after-upload branch from b6379e4 to bf6450c Compare April 25, 2018 18:57
@sayanchowdhury sayanchowdhury merged commit 4d3160c into fedora-infra:develop Apr 25, 2018
@sayanchowdhury sayanchowdhury deleted the hotfix/105-remove-images-after-upload branch April 25, 2018 19:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants