-
Notifications
You must be signed in to change notification settings - Fork 0
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: use temporary dir for package manager files #6
Conversation
Instead of relying on a fixed directory in /tmp that may or may not exist to write package manager logs to, use the tempfile library to create a temporary directory within the container for these at runtime. Also, move the functions in installer.py to a new Installer class in order to store and reuse the buildah container and mount names, the package manager, as well as the temporary directory which is created on init.
I've tested this with two DNF image configs: one from scratch and one using an existing parent. More testing would be helpful, though. |
If an error occurs in image-build, the buildah container it creates is unmounted and deleted. This can be rather unhelpful if one wants to examine package manager logs to find out more about any errors that may have occurred. Thus, this commit causes the installer to create the image-build tempdir (where the package manager cache/log files get stored) on the machine (host or container) where image-build is running. That way even if/when the buildah container is destroyed, the tempdir with the logs, etc. remains for inspection.
These files can be inspected afterward:
Things get a little funky with permissions when trying to mount a directory to
Since there are other ways to view the files if one is not root to change the permissions. I won't consider this in the scope of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this on our Redondo cluster and was able to build a rocky 9 image.
Can we double check that the documentation is still correct at https://github.com/OpenCHAMI/image-builder ? If not, let's update it and merge. It seems like the errors I was seeing are likely user error. |
I updated the README to add comments to and update the example config for the base layer. I also updated the publish section and updated the run command for the base layer to use podman instead of running bare-metal. I don't have an example of an Ansible-type layer, but can add that too if someone has one (@travisbcotton ?). |
Added example config for Ansible-type layer. This should be ready for review again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tested locally
Instead of relying on a fixed directory in
/tmp
that may or may not exist to write package manager logs/cache to, use the tempfile library to create a temporary directory within the container for these at runtime.Also, move the functions in installer.py to a new Installer class in order to store and reuse the buildah container and mount names, the package manager name, as well as the temporary directory which is created on init.
This is to avoid errors from DNF complaining that
/tmp/dnf_test
doesn't exist or that it failed to openhawkey.log
because the log directory doesn't exist.