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

[fix] Creating new temporary directory for zip files #4237

Merged
merged 1 commit into from May 21, 2024

Conversation

cservakt
Copy link
Collaborator

@cservakt cservakt commented May 6, 2024

During the storage, the zip files should be stored in one of the report folders instead of /tmp. Storing huge zip files can cause storage space saturation in /tmp.

CodeChecker store would create a new tmp directory in the first given report folder where the zip files can be stored temporarily.

@@ -894,7 +894,18 @@ def main(args):
port,
product_name=product_name)

zip_file_handle, zip_file = tempfile.mkstemp('.zip')
temp_dir = "/".join([args.input[0], "tmp"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, use the python pathlib for building file paths so the implementation is more platform independent.

zip_file_handle, zip_file = tempfile.mkstemp('.zip')
temp_dir = "/".join([args.input[0], "tmp"])
try:
if not os.path.exists(temp_dir):
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if temp_dir already exists?

@whisperity whisperity added the CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands label May 6, 2024
@cservakt cservakt requested a review from bruntib May 6, 2024 13:48
@@ -894,7 +894,16 @@ def main(args):
port,
product_name=product_name)

zip_file_handle, zip_file = tempfile.mkstemp('.zip')
try:
temp_dir = tempfile.mkdtemp(suffix="tmp", dir=args.input[0])
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
temp_dir = tempfile.mkdtemp(suffix="tmp", dir=args.input[0])
temp_dir = tempfile.mkdtemp(suffix="-store", dir=args.input[0])

We could be explicit about the fact (for posthumous spelunking of crashes at least) that the directory was caused by a store command.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great idea, much more trackable.

@@ -1007,3 +1016,4 @@ def main(args):
finally:
os.close(zip_file_handle)
os.remove(zip_file)
os.rmdir(temp_dir)
Copy link
Member

Choose a reason for hiding this comment

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

Is this the right approach?

https://docs.python.org/3/library/os.html#os.rmdir

If the directory does not exist or is not empty, a FileNotFoundError or an OSError is raised respectively.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right. The deletion is not recursive in this way. I've already fixed it with using shutil.rmtree()

During the storage, the zip files should be stored in one of the report folders instead of /tmp. Storing huge zip files can cause storage space saturation in /tmp.

CodeChecker store would create a new tmp directory in the first given report folder where the zip files can be stored temporarily.
@bruntib bruntib merged commit b1727a0 into Ericsson:master May 21, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix 🔨 CLI 💻 Related to the command-line interface, such as the cmd, store, etc. commands performance 🏃
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants