#232 Allow uploading files to non-default volumes
Merged by mikem. Opened by tkopecek.
tkopecek/koji upload-filers  into  master

Download 232.patch

uploadWrapper has a new option - volume. It allows user (or plugin, ...) upload files to other volumes than the default one.

This has also some unpleasant effects like that now we are not able to easily determine full path from relative paths/filenames. I've solved it by passing absolute paths around in affected code. It has minor effects e.g. in web ui, where larger part of path is displayed now.

Not sure if any other code path could be affected, so opening this PR for further discussion, testing and pointing out possible caveats.

Main motivation is https://pagure.io/koji/pull-request/200 (Saving failed build trees plugin) which generates big tarballs which should reside in different place than default filer.

rebased

rebased

rebased

1 new commit added

  • backward compatibility changes

I'm having trouble getting this to work. Looks like handle_upload() on the hub remains volume unaware, likewise the checkUpload() call

Forgot debug changes, new commit + rebase.

rebased

3 new commits added

  • propagate volume through hub
  • backward compatibility changes
  • Allow uploading files to non-default volumes

volume not passed to the checkUpload in fastUpload()

I adjusted that and added a unit test for it here:
https://github.com/mikem23/koji-playground/commits/upload-filers

The change in downloadTaskOutput doesn't seem right. That call should not be accepting absolute pathnames, even with the sanity check.

I think get_upload_path should pass volume through to pathinfo.work() instead of setting topdir.

rebased

I've added your commits + get_upload_path fix.

About downloadTaskOutput - not sure if I understand. I've not made any changes to that function, it was already possible to use it that way. I can add volume to its signature which could be tested in absolute pathnames codepath. So, test in assert there could be changed from:

if not fileName.startswith('/'):
    filePath = '%s/%s/%s' % (koji.pathinfo.work(), koji.pathinfo.taskrelpath(taskID), fileName)
else:
    filePath = fileName
    assert(koji.pathinfo.taskrelpath(taskID) in filePath)

to

if not fileName.startswith('/'):
    filePath = '%s/%s/%s' % (koji.pathinfo.work(volume=volume), koji.pathinfo.taskrelpath(taskID), fileName)
else:
    filePath = fileName
    assert(filePath.startswith(koji.pathinfo.task(taskID, volume)

With default volume=None it would be backward-compatible. Other option is to remove else part completely, but it means changing API.

I've removed absolute path support. Also added some more volume-aware calls in various places. Questionable stays:

  • BuildNotificationTask - listTaskOutput(all_volumes=True) is not used there, not sure if we want to pollute notification e-mail with full paths on hub - probably not
  • WrapperRpmTask - Does it make sense to use it there? I expect that also not, as it tries to put all artifacts to one directory, which simply wouldn't work with multiple files with same name.

3 new commits added

  • remove unused call
  • extend CLI multi-volume support
  • use only relative paths + volumes in downloadTaskOutput

WrapperRpmTask - Does it make sense to use it there? I expect that also not, as it tries to put all artifacts to one directory, which simply wouldn't work with multiple files with same name.

WrapperRPMTask explicitly handles that case:

https://pagure.io/koji/blob/master/f/builder/kojid#_1720

You also need to make BaseTaskHandler.localPath() volume-aware:

https://pagure.io/koji/blob/master/f/koji/tasks.py#_296

2 new commits added

  • multi-volume support for buildNotification
  • multi-volume support for wrapperRPM

Is it really needed to change localPath?

Question for wrapperRPM is also if it is semantically correct to have two artifacts with same name (differing only in volume). Should it be allowed (which means spec template logic needs to be changed, as all_artifacts will contain multiple records) or forbidden (raise an exception) or ignored?

Is it really needed to change localPath?

I don't think so. The way it is written it just takes paths relative to topdir.

Now, some of the places this call is used will need to be made volume aware.

Now, some of the places this call is used will need to be made volume aware.

Looks like you hit the important one. For the other two, the cli is not upload a file to a non-default volume, so I think those can wait until that changes.

Small patch to ensure the specified volume exists
https://github.com/mikem23/koji-playground/commits/upload-filers

Apart from that, I think this might be ready to merge

1 new commit added

  • sanity check volume field for uploads

Rebase + your patch added.

rebased

Commit f2390dad fixes this pull-request

Pull-Request has been merged by mikem@redhat.com

Metadata