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: check if cachedir is empty #4367

Merged
merged 1 commit into from
Jan 24, 2023
Merged

Conversation

PeterSchafer
Copy link
Collaborator

@PeterSchafer PeterSchafer commented Jan 24, 2023

What does this PR do?

  • Check if the specified cache directory is an empty string before trying to create it.
  • Moved some logging to main for better debugging

@PeterSchafer PeterSchafer requested a review from a team as a code owner January 24, 2023 11:30
@PeterSchafer PeterSchafer merged commit 47f32d7 into master Jan 24, 2023
@PeterSchafer PeterSchafer deleted the fix/HEAD-81_mkdir_fails branch January 24, 2023 11:45
if len(c.CacheDirectory) > 0 {
// ensure the specified base cache directory exists, this needs to be done even before acquiring the lock
if _, err = os.Stat(c.CacheDirectory); os.IsNotExist(err) {
err = os.Mkdir(c.CacheDirectory, local_utils.CACHEDIR_PERMISSION)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use mkdirall?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would, but we are having a bit of a hen-egg situation. We need the cache directory to create the lock file in, but at the same time we want protect the filesystem operations with the lock file. Originally I didn't even want to do mkdir here, but acceptance tests showed that this was necessary to remain backwards compatible. Sure it could be that multiple folders would need to be created, but again this would cause issues since mkdirall is not an atomic operation.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Solution could be to create the lock file outside of the cache directory, but this would increase our foot print in the file system and could potentially cause issues during deployment.

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.

3 participants