util.rmtree: fix for python 3
On python3, deleting a chmoded folder causes this error: Traceback (most recent call last): File "/usr/lib/python3.7/shutil.py", line 423, in _rmtree_safe_fd dirfd = os.open(entry.name, os.O_RDONLY, dir_fd=topfd) PermissionError: [Errno 13] Permission denied: 'directory' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "slapos.core/slapos/grid/slapgrid.py", line 607, in processSoftwareReleaseList software.destroy() File "slapos.core/slapos/grid/SlapObject.py", line 360, in destroy rmtree(self.software_path) File "slapos.core/slapos/util.py", line 267, in rmtree shutil.rmtree(path, onerror=chmod_retry) File "/usr/lib/python3.7/shutil.py", line 491, in rmtree _rmtree_safe_fd(fd, path, onerror) File "/usr/lib/python3.7/shutil.py", line 425, in _rmtree_safe_fd onerror(os.open, fullname, sys.exc_info()) File "slapos.core/slapos/util.py", line 264, in chmod_retry func(failed_path) TypeError: open() missing required argument 'flags' (pos 2) Our error handler was assuming that on python 3 the EACCESS for the directory would happen first on an os.lstat call [1], which is true when the top level folder is not listable, but it did not support the case where the top level folder is listable but contain another folder that is not listable. In that case, the first error is an os.open [2] Tests from erp5.util (where this function came from) only covered the 1 case but new tests in slapos.core covered the 2. Anyway, do the "chmod folder and retry from beginning" for both 1 or 2 cases. [1]: https://github.com/python/cpython/blob/3.6/Lib/shutil.py#L475 [2]: https://github.com/python/cpython/blob/3.6/Lib/shutil.py#L418
Status | Job ID | Name | Coverage | ||||||
---|---|---|---|---|---|---|---|---|---|
External | |||||||||
passed |
#103820
external
|
SlapOS.Eggs.UnitTest-Master.Python2 |
00:17:26
|
||||||
running |
#103830
external
|
SlapOS.Eggs.UnitTest-Master.Python3 |
39739:15:41 |
||||||
passed |
#103807
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python2 |
00:21:51
|
||||||
passed |
#103675
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python2 |
00:14:18
|
||||||
passed |
#103700
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python2 |
00:23:34
|
||||||
passed |
#103740
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python2 |
00:25:46
|
||||||
passed |
#103783
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python2 |
00:18:25
|
||||||
passed |
#103797
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python3 |
00:13:12
|
||||||
passed |
#103747
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python3 |
00:22:46
|
||||||
passed |
#103665
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python3 |
00:15:27
|
||||||
passed |
#103772
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python3 |
00:20:38
|
||||||
passed |
#103688
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python3 |
00:25:01
|
||||||
passed |
#103618
external
retried
|
SlapOS.Eggs.UnitTest-Master.Python3 |
00:44:56
|
||||||