Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade client for sregistry to use nginx upload module #127

Merged
merged 4 commits into from
Jul 10, 2018
Merged

Upgrade client for sregistry to use nginx upload module #127

merged 4 commits into from
Jul 10, 2018

Conversation

vsoch
Copy link
Member

@vsoch vsoch commented Jun 16, 2018

This PR will close the following issues related to not being able to upload large containers:

This is the branch that should be used to test uploading to singularityhub/sregistry#134 (the old method will no longer work)

I had originally planned to add chunked upload to Singularity Registry server. I did, and this was a web interface with a progress bar, etc. I was not happy with trying to get the same for an upload from the command line, so I scratched django chunked upload. Instead, I am using nginx upload module to (super speedily) upload files directly to the server from nginx.

In the code to do the push, you will now see two authentication checks. Both send an encrypted payload (with the user's token secret) to the server, and this payload is used to identify the user, check permissions, and finally authenticate the upload request. The first time a collection is returned (and permissions are checked) and we only continue if permissions are adequate. On the server the collection is created if the user has permission to do so and it doesn't exist, and of course a user that doesn't have permission cannot proceed beyond this point.

The second post uses multipart form encoded data to submit directly to the django_upload module, and the callback view then does the equivalent permissions checks, and only continues with processing the upload if everything is (still) ok. I suspect we will want some level of checking permissions on the level of the nginx module, but this can come later (and isn't relevant for this PR anyway).

@fearful-symmetry
Copy link

I...can't seem to get this working to test singularityhub/sregistry#134.
steps:

$ python3 -m venv sreg-test
$ cd sreg-test/
$ git clone https://github.com/singularityhub/sregistry-cli.git
$ cd sregistry-cli/
$ git fetch origin pull/127/head:add/chunked-upload
$ git checkout add/chunked-upload
$ source ../bin/activate.fish
$ python3 setup.py install
$sregistry images                                                                                                                                                                                            
WARNING Database disabled. Install sqlalchemy for full functionality
WARNING Singularity is not installed, function might be limited.
WARNING Singularity is not installed, function might be limited.
Traceback (most recent call last):
  File "/home/jensend/sreg-test/bin/sregistry", line 11, in <module>
    load_entry_point('sregistry==0.0.87', 'console_scripts', 'sregistry')()
  File "/home/jensend/sreg-test/lib/python3.6/site-packages/sregistry-0.0.87-py3.6.egg/sregistry/client/__init__.py", line 380, in main
    subparser=subparsers[args.command])
  File "/home/jensend/sreg-test/lib/python3.6/site-packages/sregistry-0.0.87-py3.6.egg/sregistry/client/images.py", line 33, in main
    cli.images(query=query)
AttributeError: 'Client' object has no attribute 'images'

@vsoch
Copy link
Member Author

vsoch commented Jun 19, 2018

Taking a look!

@vsoch
Copy link
Member Author

vsoch commented Jun 19, 2018

AH okay I see what is going on! Your virtual environment doesn't have sqlalchemy installed (see the first WARNING) and this is a valid use case given that you want to move containers around, but not store them in a database. The images command, however, is intended to show the containers in your database. So you should be able to install sqlalchemy to fix this issue, and what I need to do is put a meaningful error message to address this. Give me a few minutes and I'll see what I can do!

@vsoch
Copy link
Member Author

vsoch commented Jun 19, 2018

okay I've just pushed a change that will remove the "images" command entirely as an option, given that sqlalchemy isn't installed.

@fearful-symmetry
Copy link

Ah, my bad. I assumed that images would reach out to the remote sregistry server. looks like the command I was searching for was sregistry search

@vsoch
Copy link
Member Author

vsoch commented Jun 19, 2018

@fearful-symmetry another thought that might be your issue - if you aren't supplying the name or are giving one that would weirdly result in "None" (e.g. --name) then the name could return a value of None and trigger an error like you are seeing. I would want to put in some check for this case (if it is the case!)

@vsoch vsoch merged commit 12c2a59 into singularityhub:master Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants