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

ApplyLayer exit status 1 stdout: stderr: mkdir XXX: file exists #122

Closed
goldmann opened this issue Sep 1, 2016 · 0 comments
Closed

ApplyLayer exit status 1 stdout: stderr: mkdir XXX: file exists #122

goldmann opened this issue Sep 1, 2016 · 0 comments
Labels
Milestone

Comments

@goldmann
Copy link
Owner

goldmann commented Sep 1, 2016

In a special case where we add/remove directories and files and create a new files instead of them with symlinks, squashing fails.

2016-08-31 09:21:04,208 - atomic_reactor.plugins.squash - DEBUG - Moving unmodified layer '47eed7a8ea3f131e9281ae09fcbfb0041872fd8b74a048f1c739302c8148505d'...
2016-08-31 09:21:04,209 - atomic_reactor.plugins.squash - DEBUG - Reading JSON metadata file '/tmp/docker-squash-qIEDpw/old/5e1910ede4695eb330b6e2c9fed29944f06c5798ad49c6d13a7d60ab09ca89b9/json'...
2016-08-31 09:21:04,209 - atomic_reactor.plugins.squash - INFO - New squashed image ID is 2ffce21bb64dc3c32b385ee916fe82a3d2d5a6788c41b4c2316ea61697c254dd
2016-08-31 09:21:04,210 - atomic_reactor.plugins.squash - DEBUG - Generating tar archive for the squashed image...
2016-08-31 09:21:05,252 - atomic_reactor.plugins.squash - DEBUG - Archive generated
2016-08-31 09:21:05,252 - atomic_reactor.plugins.squash - INFO - Image available at '/tmp/tmpYrpS4t/image.tar'
2016-08-31 09:21:05,252 - atomic_reactor.plugins.squash - DEBUG - Generating tar archive for the squashed image...
2016-08-31 09:21:06,300 - atomic_reactor.plugins.squash - DEBUG - Archive generated
2016-08-31 09:21:06,300 - atomic_reactor.plugins.squash - DEBUG - Loading squashed image...
2016-08-31 09:22:10,414 - atomic_reactor.plugins.squash - DEBUG - Cleaning up /tmp/docker-squash-qIEDpw temporary directory
2016-08-31 09:22:10,855 - atomic_reactor.plugin - DEBUG - Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/atomic_reactor/plugin.py", line 211, in run
    plugin_response = plugin_instance.run()
  File "/usr/lib/python2.7/site-packages/atomic_reactor/plugins/prepub_squash.py", line 97, in run
    tag=self.tag, output_path=metadata["path"], load_image=True).run()
  File "/usr/lib/python2.7/site-packages/docker_squash/squash.py", line 59, in run
    return self.squash(image)
  File "/usr/lib/python2.7/site-packages/docker_squash/squash.py", line 92, in squash
    image.load_squashed_image()
  File "/usr/lib/python2.7/site-packages/docker_squash/image.py", line 233, in load_squashed_image
    self._load_image(self.new_image_dir)
  File "/usr/lib/python2.7/site-packages/docker_squash/image.py", line 278, in _load_image
    self.docker.load_image(f)
  File "/usr/lib/python2.7/site-packages/docker/api/image.py", line 153, in load_image
    self._raise_for_status(res)
  File "/usr/lib/python2.7/site-packages/docker/client.py", line 146, in _raise_for_status
    raise errors.APIError(e, response, explanation=explanation)
APIError: 500 Server Error: Internal Server Error ("ApplyLayer exit status 1 stdout:  stderr: mkdir /etc/systemd/system: file exists")

This can be reproduced with this simple Dockerfile:

FROM busybox:1.24
RUN mkdir -p /etc/systemd/system/multi-user.target.wants
RUN mkdir -p /etc/systemd/system/default.target.wants
RUN touch /etc/systemd/system/multi-user.target.wants/remote-fs.target
RUN touch /etc/systemd/system/default.target.wants/remote-fs.target
# End of preparations, going to squash from here
RUN find /etc/systemd/system/* '!' -name '*.wants' | xargs rm -rvf
RUN rmdir -v /etc/systemd/system/multi-user.target.wants && mkdir /etc/systemd/system/container-ipa.target.wants && ln -s /etc/systemd/system/container-ipa.target.wants /etc/systemd/system/multi-user.target.wants
RUN ln -s /etc/group /etc/systemd/system/default.target
RUN ln -s /etc/group /etc/systemd/system/container-ipa.target.wants/ipa-server-configure-first.service
RUN echo "/etc/systemd/system" > /etc/volume-data-list
RUN set -e ; cd / ; mkdir /data-template ; cat /etc/volume-data-list | while read i ; do echo $i ; if [ -e $i ] ; then tar cf - .$i | ( cd /data-template && tar xf - ) ; fi ; mkdir -p $( dirname $i ) ; if [ "$i" == /var/log/ ] ; then mv /var/log /var/log-removed ; else rm -rf $i ; fi ; ln -sf /data$i $i ; done
@goldmann goldmann added this to the 1.0.4 milestone Sep 1, 2016
goldmann added a commit that referenced this issue Sep 1, 2016
When we add a file back to the tar we need to check
if the parent (or some parent of it) is a symlink.
We should not add any files in such case.

Fixes #122.
goldmann added a commit that referenced this issue Sep 1, 2016
Files added when parent directory is a symlink
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant