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

Self cleanup on stop hook #20

Merged
merged 2 commits into from Oct 19, 2016
Merged

Self cleanup on stop hook #20

merged 2 commits into from Oct 19, 2016

Conversation

lazypower
Copy link
Contributor

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 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
@wwwtyro
Copy link
Contributor

wwwtyro commented Oct 19, 2016

👍 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:
Copy link
Contributor

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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)?

@mbruzek
Copy link
Contributor

mbruzek commented Oct 19, 2016

I am +1 to attempting to clean up after ourselves on the stop hook. My one comment was to handle exceptions when deleting files.

@mbruzek mbruzek merged commit 30c6d75 into charmed-kubernetes:master Oct 19, 2016
@lazypower
Copy link
Contributor Author

It's a good comment. I filed #21 to track that comment as the code has landed.

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