Issue #7698
closedError when syncing a remote if systemd working dir is set to ~
Description
a recent change: https://github.com/theforeman/puppet-pulpcore/commit/b3b7c133c513dd2c30b00a81e64b2bb33ca92397
caused this error when syncing a remote:
File "/usr/lib/python3.6/site-packages/rq/job.py", line 684, in perform
self._result = self._execute()
File "/usr/lib/python3.6/site-packages/rq/job.py", line 690, in _execute
return self.func(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/tasks/synchronizing.py", line 213, in synchronize
remote_url = fetch_remote_url(remote)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/tasks/synchronizing.py", line 138, in fetch_remote_url
downloader.fetch()
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 160, in fetch
return done.pop().result()
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 227, in run
return await self._run(extra_data=extra_data)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/downloaders.py", line 89, in _run
to_return = await self._handle_response(response)
File "/usr/lib/python3.6/site-packages/pulpcore/download/http.py", line 184, in _handle_response
await self.handle_data(chunk)
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 123, in handle_data
self._ensure_writer_has_open_file()
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 108, in _ensure_writer_has_open_file
self._writer = tempfile.NamedTemporaryFile(dir=os.getcwd(), delete=False)
File "/usr/lib64/python3.6/tempfile.py", line 551, in NamedTemporaryFile
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/usr/lib64/python3.6/tempfile.py", line 262, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
PermissionError: [Errno 13] Permission denied: '/tmpw64sk7in'
Traceback (most recent call last):
File "/usr/lib/python3.6/site-packages/rq/worker.py", line 936, in perform_job
rv = job.perform()
File "/usr/lib/python3.6/site-packages/rq/job.py", line 684, in perform
self._result = self._execute()
File "/usr/lib/python3.6/site-packages/rq/job.py", line 690, in _execute
return self.func(*self.args, **self.kwargs)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/tasks/synchronizing.py", line 213, in synchronize
remote_url = fetch_remote_url(remote)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/tasks/synchronizing.py", line 138, in fetch_remote_url
downloader.fetch()
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 160, in fetch
return done.pop().result()
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 227, in run
return await self._run(extra_data=extra_data)
File "/usr/lib/python3.6/site-packages/pulp_rpm/app/downloaders.py", line 89, in _run
to_return = await self._handle_response(response)
File "/usr/lib/python3.6/site-packages/pulpcore/download/http.py", line 184, in _handle_response
await self.handle_data(chunk)
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 123, in handle_data
self._ensure_writer_has_open_file()
File "/usr/lib/python3.6/site-packages/pulpcore/download/base.py", line 108, in _ensure_writer_has_open_file
self._writer = tempfile.NamedTemporaryFile(dir=os.getcwd(), delete=False)
File "/usr/lib64/python3.6/tempfile.py", line 551, in NamedTemporaryFile
(fd, name) = _mkstemp_inner(dir, prefix, suffix, flags, output_type)
File "/usr/lib64/python3.6/tempfile.py", line 262, in _mkstemp_inner
fd = _os.open(file, flags, 0o600)
PermissionError: [Errno 13] Permission denied: '/tmpw64sk7in'
Updated by dkliban@redhat.com about 4 years ago
The download of repomd.xml occurs outside of the WorkingDirectory context manager[0]. The WorkingDirectory context manager does not seem to be used anywhere in the synchronize task.
[0] https://github.com/pulp/pulp_rpm/blob/3.7/pulp_rpm/app/tasks/synchronizing.py#L138
Updated by ekohl about 4 years ago
It's important to note we discovered WorkingDirectory=~ isn't supported in EL7's systemd version. In https://github.com/theforeman/puppet-pulpcore/commit/4bb4942c7be1cbd8466a703a4ee4dc7071713ead we changed it to absolute paths. That may have been the cause because it could have ended up working in /.
Updated by ttereshc about 4 years ago
- Triaged changed from No to Yes
- Sprint set to Sprint 83
Updated by ppicka about 4 years ago
- Status changed from NEW to ASSIGNED
- Assignee set to ppicka
Updated by pulpbot about 4 years ago
- Status changed from ASSIGNED to POST
Added by ppicka about 4 years ago
Updated by ppicka about 4 years ago
- Status changed from POST to MODIFIED
Applied in changeset 86162493ecd8de251860d9f5a188d7317ea0f9cc.
Updated by pulpbot about 4 years ago
- Status changed from MODIFIED to CLOSED - CURRENTRELEASE
Sync to happen inside working directory
few downloads or testing remote remomd.xml file happened outside a working directory
[nocoverage] [notest]
closes: #7698 https://pulp.plan.io/issues/7698