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

Temporary files should be created in $TMPDIR #1141

Closed
zstyblik opened this Issue Feb 20, 2018 · 10 comments

Comments

Projects
None yet
3 participants
@zstyblik

zstyblik commented Feb 20, 2018

Issue Type

  • Bug report

Molecule and Ansible details

pip install 'molecule==2.8.2'

Desired Behaviour

molecule should place temporary files in $TMPDIR and not anywhere in $CWD or $CWD/molecule

Actual Behaviour (Bug report only)

$ docker run -t --rm -v /some/host/path:/source:ro some:image molecule lint
Traceback (most recent call last):
  File "/usr/bin/molecule", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python2.7/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/lib/python2.7/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python2.7/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/molecule/command/lint.py", line 82, in lint
    base.get_configs(args, command_args), scenario_name)
  File "/usr/lib/python2.7/site-packages/molecule/command/base.py", line 121, in get_configs
    _verify_configs(configs)
  File "/usr/lib/python2.7/site-packages/molecule/command/base.py", line 134, in _verify_configs
    scenario_names = [c.scenario.name for c in configs]
  File "/usr/lib/python2.7/site-packages/molecule/config.py", line 201, in scenario
    return scenario.Scenario(self)
  File "/usr/lib/python2.7/site-packages/molecule/scenario.py", line 82, in __init__
    self._setup()
  File "/usr/lib/python2.7/site-packages/molecule/scenario.py", line 170, in _setup
    os.mkdir(self.ephemeral_directory)
OSError: [Errno 30] Read-only file system: '/source/molecule/default/.molecule'

Thank you.

@retr0h

This comment has been minimized.

Contributor

retr0h commented Feb 20, 2018

Unfortunately this is where molecule stores it's file. This isn't going to change anytime soon.

@retr0h retr0h added the wontfix label Feb 20, 2018

@zstyblik

This comment has been minimized.

zstyblik commented Feb 21, 2018

I'm not sure why "wontfix", but ok.

@retr0h

This comment has been minimized.

Contributor

retr0h commented Feb 21, 2018

Molecule is built around an ephemeral directory and temp files inside there. Reworking to $TMPDIR is a larger effort. Cannot fix this at the moment, granted it is a good suggestion.

@retr0h

This comment has been minimized.

Contributor

retr0h commented Feb 21, 2018

@dj-wasabi interested or have the time to grab this one?

@elliotweiser

This comment has been minimized.

Contributor

elliotweiser commented Mar 25, 2018

@retr0h I can take a crack at this. Seems like a good way to get into the internals.

@retr0h retr0h referenced this issue Mar 25, 2018

Closed

Question #1202

@retr0h

This comment has been minimized.

Contributor

retr0h commented Mar 27, 2018

@retr0h retr0h added the v2.12 label Mar 30, 2018

retr0h added a commit to retr0h/molecule that referenced this issue Mar 30, 2018

Moved temporary files to $TMPDIR
* Temporary files are now created under $TEMPDIR.  This is
  especially useful for users which run Molecule under a ro
  docker volume.
* Wrapped properties which instantiate a class with a simple
  memoize decorator.  Molecule was instantiating classes on each
  property access.

Fixes: ansible#1141

retr0h added a commit to retr0h/molecule that referenced this issue Mar 30, 2018

Moved temporary files to $TMPDIR
* Temporary files are now created under $TEMPDIR.  This is
  especially useful for users which run Molecule under a ro
  docker volume.
* Wrapped properties which instantiate a class with a simple
  memoize decorator.  Molecule was instantiating classes on each
  property access.

Fixes: ansible#1141

retr0h added a commit to retr0h/molecule that referenced this issue Mar 30, 2018

Moved temporary files to $TMPDIR
* Temporary files are now created under $TEMPDIR.  This is
  especially useful for users which run Molecule under a ro
  docker volume.
* Wrapped properties which instantiate a class with a simple
  memoize decorator.  Molecule was instantiating classes on each
  property access.

Fixes: ansible#1141

@retr0h retr0h closed this in #1218 Mar 30, 2018

retr0h added a commit that referenced this issue Mar 30, 2018

Moved temporary files to $TMPDIR (#1218)
* Temporary files are now created under $TEMPDIR.  This is
  especially useful for users which run Molecule under a ro
  docker volume.
* Wrapped properties which instantiate a class with a simple
  memoize decorator.  Molecule was instantiating classes on each
  property access.

Fixes: #1141
@elliotweiser

This comment has been minimized.

Contributor

elliotweiser commented Mar 30, 2018

@retr0h beat me to it 😄 I can probably give it a test run this weekend.

@retr0h

This comment has been minimized.

Contributor

retr0h commented Apr 1, 2018

@elliotweiser sweet. I should have a 2.12 hot off the presses shortly.

@retr0h

This comment has been minimized.

Contributor

retr0h commented Apr 1, 2018

Now testinfra complains when running Molecule with dind and r/o volume. However, we no longer have the issue with molecue writing files to $TMPDIR. I'll look into this separately.

py.error.EROFS: [Read-only file system]: mkdir('/tmp/foo/molecule/default/.pytest_cache',)

retr0h added a commit to retr0h/molecule that referenced this issue Apr 1, 2018

Disable pytest caching plugin
* Prevent `.pytest_cache` files from being created in the checkout.
* Allow dind read-only volumes to function.

Fixes: ansible#1141

retr0h added a commit that referenced this issue Apr 1, 2018

Disable pytest caching plugin (#1227)
* Prevent `.pytest_cache` files from being created in the checkout.
* Allow dind read-only volumes to function.

Fixes: #1141
@retr0h

This comment has been minimized.

Contributor

retr0h commented Apr 1, 2018

Corrected in 2.12.1 and updated dind instructions with read-only volume.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment