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
Self cleanup on stop hook #20
Conversation
This code path bloats the teardown time by about 20 seconds, but successfully cleans up the interface and the associated files upon executing the stop hook
👍 This looks fine to me, not confident about merging until the cleanup discussion is resolved or @mbruzek or @marcoceppi give a thumbs up. |
try: | ||
subprocess.check_call(down) | ||
subprocess.check_call(delete) | ||
except subprocess.CalledProcessError: |
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.
If we're going to ignore this exception here, can we at least log it for troubleshooting purposes?
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.
👍 good shout. I'll add some debug messaging.
for f in files: | ||
if os.path.exists(f): | ||
hookenv.log('Removing {}'.format(f)) | ||
os.remove(f) |
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.
Should we do this os.remove in a try/except to soldier on if we got a file we can not delete (for example if it was in use at the time of delete attempt)?
I am +1 to attempting to clean up after ourselves on the stop hook. My one comment was to handle exceptions when deleting files. |
It's a good comment. I filed #21 to track that comment as the code has landed. |
This code path bloats the teardown time by about 20 seconds, but
successfully cleans up the interface and the associated files upon
executing the stop hook