perf: 上传目标目录指定在/tmp下 (#12334)

Co-authored-by: wangruidong <940853815@qq.com>
pull/12337/head
fit2bot 12 months ago committed by GitHub
parent 438e9dee2a
commit e3c0518cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -93,7 +93,7 @@ class UploadFileRunner:
self.cb = DefaultCallback() self.cb = DefaultCallback()
upload_file_dir = safe_join(settings.DATA_DIR, 'job_upload_file') upload_file_dir = safe_join(settings.DATA_DIR, 'job_upload_file')
self.src_paths = safe_join(upload_file_dir, str(job_id)) self.src_paths = safe_join(upload_file_dir, str(job_id))
self.dest_path = dest_path self.dest_path = safe_join("/tmp", dest_path)
def run(self, verbosity=0, **kwargs): def run(self, verbosity=0, **kwargs):
verbosity = get_ansible_log_verbosity(verbosity) verbosity = get_ansible_log_verbosity(verbosity)

@ -68,7 +68,7 @@ class JobViewSet(OrgBulkModelViewSet):
def get_queryset(self): def get_queryset(self):
queryset = super().get_queryset() queryset = super().get_queryset()
queryset = queryset.filter(creator=self.request.user) queryset = queryset.filter(creator=self.request.user).exclude(type=Types.upload_file)
if self.action != 'retrieve': if self.action != 'retrieve':
return queryset.filter(instant=False) return queryset.filter(instant=False)
return queryset return queryset

@ -381,11 +381,8 @@ class JobExecution(JMSOrgBaseModel):
elif self.current_job.type == Types.upload_file: elif self.current_job.type == Types.upload_file:
job_id = self.current_job.id job_id = self.current_job.id
args = json.loads(self.current_job.args) args = json.loads(self.current_job.args)
dst_path = args.get('dst_path') dst_path = args.get('dst_path', '/')
if dst_path: runner = UploadFileRunner(self.inventory_path, job_id, dst_path)
runner = UploadFileRunner(self.inventory_path, job_id, dst_path)
else:
raise ValueError("dst_path is null")
else: else:
raise Exception("unsupported job type") raise Exception("unsupported job type")
return runner return runner

Loading…
Cancel
Save