Issue #6504
closedWorkerDirectory.delete() permission fixing causes infinite recursion
Description
def delete(self):
"""
Delete the directory.
On permission denied - an attempt is made to recursively fix the
permissions on the tree and the delete is retried.
"""
try:
shutil.rmtree(self.path)
except FileNotFoundError:
pass
except PermissionError:
self._set_permissions()
self.delete() # <--- RIGHT HERE
WorkerDirectory.delete() attempts to fix permissions and call itself to retry deletion when it fails due to permissions. If this does not fix the problem, it will caues an infinite recursion, raise a RecursionError, and the job will fail.
resource-manager_1 | Traceback (most recent call last):
resource-manager_1 | File "/venv/bin/rq", line 8, in <module>
resource-manager_1 | sys.exit(main())
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/click/core.py", line 829, in __call__
resource-manager_1 | return self.main(*args, **kwargs)
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/click/core.py", line 782, in main
resource-manager_1 | rv = self.invoke(ctx)
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/click/core.py", line 1259, in invoke
resource-manager_1 | return _process_result(sub_ctx.command.invoke(sub_ctx))
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/click/core.py", line 1066, in invoke
resource-manager_1 | return ctx.invoke(self.callback, **ctx.params)
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/click/core.py", line 610, in invoke
resource-manager_1 | return callback(*args, **kwargs)
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/rq/cli/cli.py", line 78, in wrapper
resource-manager_1 | return ctx.invoke(func, cli_config, *args[1:], **kwargs)
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/click/core.py", line 610, in invoke
resource-manager_1 | return callback(*args, **kwargs)
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/rq/cli/cli.py", line 259, in worker
resource-manager_1 | max_jobs=max_jobs, with_scheduler=with_scheduler)
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/rq/worker.py", line 474, in work
resource-manager_1 | self.register_birth()
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/pulpcore/tasking/worker.py", line 158, in register_birth
resource-manager_1 | working_dir.delete()
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/pulpcore/tasking/services/storage.py", line 83, in delete
resource-manager_1 | self.delete()
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/pulpcore/tasking/services/storage.py", line 83, in delete
resource-manager_1 | self.delete()
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/pulpcore/tasking/services/storage.py", line 83, in delete
resource-manager_1 | self.delete()
resource-manager_1 | [Previous line repeated 972 more times]
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/pulpcore/tasking/services/storage.py", line 82, in delete
resource-manager_1 | self._set_permissions()
resource-manager_1 | File "/venv/lib64/python3.6/site-packages/pulpcore/tasking/services/storage.py", line 89, in _set_permissions
resource-manager_1 | for path in os.walk(self.path):
resource-manager_1 | RecursionError: maximum recursion depth exceeded
Updated by fao89 over 4 years ago
- Triaged changed from No to Yes
- Sprint set to Sprint 70
Updated by pulpbot over 4 years ago
- Status changed from NEW to POST
Added by gerrod over 4 years ago
Updated by gerrod over 4 years ago
- Status changed from POST to MODIFIED
Applied in changeset pulpcore|39954c1d70c6fb421528976cb5b125d7850b1eac.
Added by gerrod over 4 years ago
Revision 9047be17 | View on GitHub
Fixed WorkerDirectory.delete() causing infinite recursion when permission errors occur
WorkerDirectory.delete() now only trys one additional time to delete its directory tree after encountering a PermissionError
fixes #6504 https://pulp.plan.io/issues/6504
(cherry picked from commit 39954c1d70c6fb421528976cb5b125d7850b1eac)
Updated by gerrod over 4 years ago
Applied in changeset pulpcore|9047be1740fe398dd67629b374bd7311426f0bf3.
Updated by pulpbot over 4 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Fixed WorkerDirectory.delete() causing infinite recursion when permission errors occur
WorkerDirectory.delete() now only trys one additional time to delete its directory tree after encountering a PermissionError
fixes #6504 https://pulp.plan.io/issues/6504