Skip to content

Remove temp files created by submit_debug_info #2714

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

Merged
merged 2 commits into from
May 27, 2016

Conversation

vcabbage
Copy link
Contributor

Currently submit_debug_info.py doesn't clean up the the temp files it creates. This PR adds a finally statement to remove the temp files created by the create_archive function.

Added a remove_dir function to st2debug/utils/fs.py for consistency with the remove_file function.

@Kami
Copy link
Member

Kami commented May 26, 2016

Great, thanks.

We also need to make sure directory and file is not removed when using --review option, right?

@vcabbage
Copy link
Contributor Author

According to the description, --review generates the tarball. This only removes the temp dir, the tarball will still be output.

    parser.add_argument('--review', action='store_true', default=False,
                        help='Generate the tarball, but don\'t encrypt and upload it')

@Kami
Copy link
Member

Kami commented May 26, 2016

@vcabbage Alright, great - then we should be fine.

On a related note - it would be great if you can add a test case for this change.

@vcabbage
Copy link
Contributor Author

Difficult to test as written. I could check the number of files int /tmp and verify there are no additional files after create_archive is run, though that sounds a bit flaky. Or I could save the temp dir path to an attribute and check for it's existence directly.

Do you have a preference (or better approach)?

@Kami
Copy link
Member

Kami commented May 26, 2016

Would need to dig in, but in short, we would probably need to modify some methods to store a list of directories and files which are created...

@vcabbage
Copy link
Contributor Author

Since it deletes the entire directory I added a test to check if the directory exists after running. Let me know if that works.

@Kami
Copy link
Member

Kami commented May 27, 2016

Yep, that works - thanks!

@Kami Kami merged commit b6b4d11 into StackStorm:master May 27, 2016
@Kami
Copy link
Member

Kami commented May 27, 2016

Merged, thanks.

@vcabbage vcabbage deleted the kale/submit-debug-cleanup-tmp branch May 27, 2016 15:11
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.

2 participants