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

helper: Make sure directories are created before they are passed to container engine (podman) #4763

Merged
merged 1 commit into from
Dec 1, 2020

Conversation

Jakuje
Copy link
Contributor

@Jakuje Jakuje commented Dec 1, 2020

As discussed recently in the containers/podman#8513, there is deliberate difference in the CLI of podman and docker in context of creation of missing directories passed as -v arguments. While docker happily creates these, podman is not that generous requires the directory structure to be ready in advance.

This PR makes sure directories are in place before invoking podman (symlinked from docker by default).

I am running oss-fuzz with podman for several years, reproducing issues and all works fine aside of couple of quirks that I would like to capture in this and probably some more PRs, if they will be acceptable.

infra/helper.py Outdated
@@ -278,17 +278,29 @@ def get_dockerfile_path(project_name):

def _get_corpus_dir(project_name=''):
"""Returns path to /corpus directory for the given project (if specified)."""
return os.path.join(BUILD_DIR, 'corpus', project_name)
path = os.path.join(BUILD_DIR, 'corpus', project_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think 'corpus' is guaranteed to exist. So how about you use
os.makedirs(directory, exist_ok=True).
This will make the parent directory and remove the need for checking the directory exists.

Also, could you please update the docstrings of these functions to reflect the fact that they create the directories if they don't already exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think you are right. I think the same issue will be with the other ones, as the only created path is at this moment BUILD_DIR.

Added also docstrings. I wanted to keep that sort so hope it is still understandable.

@jonathanmetzman
Copy link
Contributor

Thanks, I just want some small changes before merging this.

@jonathanmetzman
Copy link
Contributor

Thanks, looks like line 288 is slightly too long (102 chars instead of 100 according to CI) can you fix and try pushing again please.
You can lint the code if you install the requirements in infra/ci/requirements.txt and run python infra/helper.py presubmit

@Jakuje
Copy link
Contributor Author

Jakuje commented Dec 1, 2020

Thanks, looks like line 288 is slightly too long (102 chars instead of 100 according to CI) can you fix and try pushing again please.

Sorry. Fixed now.

Copy link
Contributor

@jonathanmetzman jonathanmetzman left a comment

Choose a reason for hiding this comment

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

LGTM

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