use symlinks for file:// urls
ClosedPublic

Authored by lbrabec on Aug 12 2016, 8:24 AM.

Details

Summary

Images with file:// url are not copied to /var/lib/testcloud/backingstores/,
instead symlink is created, changing selinux context is set to not follow
symlinks.

Test Plan

manually run testcloud

Diff Detail

Repository
rTCLOUD testcloud
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
lbrabec retitled this revision from to use symlinks for file:// urls.Aug 12 2016, 8:24 AM
lbrabec updated this object.
lbrabec edited the test plan for this revision. (Show Details)
lbrabec added a reviewer: kparal.
lbrabec updated this revision to Diff 2478.Aug 12 2016, 11:41 AM
  • copy on default
lbrabec updated this revision to Diff 2479.Aug 12 2016, 11:47 AM
  • copy on default
kparal requested changes to this revision.Aug 12 2016, 12:21 PM

Hit a race condition when I executed two processes simultaneously:

Traceback (most recent call last):
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/minion.py", line 244, in execute
    task_vm.teardown()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/ext/disposable/vm.py", line 174, in teardown
    tc_instance = self._check_existing_instance(should_exist=True)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/ext/disposable/vm.py", line 118, in _check_existing_instance
    " already exist".format(self.instancename))
TaskotronRemoteError: Was expecting to find instance taskotron-20160812_121309_083416 but it does not already exist
[libtaskotron] 12:13:09 CRITICAL Traceback (most recent call last):
  File "/home/kparal/devel/taskotron/env_taskotron/bin/runtask", line 9, in <module>
    load_entry_point('libtaskotron==0.4.14', 'console_scripts', 'runtask')()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/main.py", line 163, in main
    overlord.start()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/overlord.py", line 92, in start
    runner.execute()
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/minion.py", line 203, in execute
    task_vm.prepare(**env)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/ext/disposable/vm.py", line 136, in prepare
    tc_image = self._prepare_image(distro, release, flavor, arch)
  File "/home/kparal/devel/taskotron/libtaskotron/libtaskotron/ext/disposable/vm.py", line 87, in _prepare_image
    tc_image.prepare(copy=False)
  File "/home/kparal/devel/testcloud/testcloud/image.py", line 202, in prepare
    self._handle_file_url(self.remote_path, self.local_path, copy=copy)
  File "/home/kparal/devel/testcloud/testcloud/image.py", line 165, in _handle_file_url
    os.symlink(source_path, dest_path)
OSError: [Errno 17] File exists

We either need to overwrite the symlink when creating it or move it (and overwrite) from a tmp dir.

testcloud/image.py
160

It would be nice to document what copy=False means (not obvious).

193

Same as above.

This revision now requires changes to proceed.Aug 12 2016, 12:21 PM
lbrabec updated this revision to Diff 2480.Aug 12 2016, 12:31 PM
  • atomic creation of symlink
lbrabec updated this revision to Diff 2481.Aug 12 2016, 12:44 PM
  • subprocess solution
kparal accepted this revision.Aug 12 2016, 12:49 PM
kparal added reviewers: testcloud, tflink.

I tested it, seems to work for me.

This revision is now accepted and ready to land.Aug 12 2016, 12:49 PM

Also, please adjust the docstring at least for prepare, thanks.

tflink accepted this revision.Aug 12 2016, 12:54 PM

LGTM so long as the docstrings are updated

Closed by commit rTCLOUDe3c14d483184: use symlinks for file:// urls (authored by Lukas Brabec <lbrabec@redhat.com>). · Explain WhyAug 12 2016, 1:00 PM
This revision was automatically updated to reflect the committed changes.