The source project of this merge request has been removed.
Race condition when creating installation directories
Fix for https://its.cern.ch/jira/browse/GAUDI-1105.
I wrote a test case, but it's a bugger to reproduce as the race condition has to happen between lines 223 and 225. However, tweaking the original and patched install.py
scripts to manually create the race (by doing makedirs()
twice) I can show the patch works fine.
Original:
teal:~/cernbox/code/graemes/Gaudi/GaudiPolicy/tests/GAUDI-1105$ ./test_install.py
Create dir '/Users/graemes/cernbox/code/graemes/Gaudi/GaudiPolicy/tests/GAUDI-1105/testModuleDir-b82ed798-4e3c-4a33-b037-649c2a30bc75'
Traceback (most recent call last):
File "/Users/graemes/cernbox/code/gaudi/Gaudi/GaudiPolicy/scripts/install.py", line 314, in <module>
main()
File "/Users/graemes/cernbox/code/gaudi/Gaudi/GaudiPolicy/scripts/install.py", line 84, in main
opts.symlink, realpath(dirname(opts.logfile)))
File "/Users/graemes/cernbox/code/gaudi/Gaudi/GaudiPolicy/scripts/install.py", line 271, in install
update(src,dest,old_dest,syml,logdir)
File "/Users/graemes/cernbox/code/gaudi/Gaudi/GaudiPolicy/scripts/install.py", line 227, in update
makedirs(dest_path)
File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 17] File exists: '/Users/graemes/cernbox/code/graemes/Gaudi/GaudiPolicy/tests/GAUDI-1105/testModuleDir-b82ed798-4e3c-4a33-b037-649c2a30bc75'
F
======================================================================
FAIL: test_installToExisitingPath (__main__.installTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "./test_install.py", line 39, in test_installToExisitingPath
self.assertEqual(rc, 0)
AssertionError: 1 != 0
----------------------------------------------------------------------
Ran 1 test in 0.035s
FAILED (failures=1)
Patched:
teal:~/cernbox/code/graemes/Gaudi/GaudiPolicy/tests/GAUDI-1105$ ./test_install.py
Copy '../testModule-d9786052-eb64-497a-878d-92dd241d1c68.py' -> '/Users/graemes/cernbox/code/graemes/Gaudi/GaudiPolicy/tests/GAUDI-1105/testModuleDir-fb5a280c-c8e4-4cb1-84d8-21ae4ccc6574/testModule-d9786052-eb64-497a-878d-92dd241d1c68.py'
.
----------------------------------------------------------------------
Ran 1 test in 0.036s
OK