Project

Profile

Help

Issue #6504

closed

WorkerDirectory.delete() permission fixing causes infinite recursion

Added by ironfroggy over 4 years ago. Updated over 4 years ago.

Status:
CLOSED - CURRENTRELEASE
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
Start date:
Due date:
Estimated time:
Severity:
2. Medium
Version:
Platform Release:
OS:
Triaged:
Yes
Groomed:
No
Sprint Candidate:
No
Tags:
Sprint:
Sprint 76
Quarter:

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

Also available in: Atom PDF