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

Unable to list deployments #6

Open
nuwang opened this issue Apr 5, 2018 · 7 comments
Open

Unable to list deployments #6

nuwang opened this issue Apr 5, 2018 · 7 comments

Comments

@nuwang
Copy link
Contributor

nuwang commented Apr 5, 2018

  • Python version: 3.6.2
  • Operating System: OsX

Description

Trying to list deployments using the cli client results in an exception.

What I Did

(cloudlaunch-cli)Nuwan@Nuwans-MBP-2 cloudlaunch_cli (master)$ cloudlaunch deployments list
Traceback (most recent call last):
  File "/Users/Nuwan/work/cloudlaunch-cli/venv/bin/cloudlaunch", line 11, in <module>
    load_entry_point('cloudlaunch-cli', 'console_scripts', 'cloudlaunch')()
  File "/Users/Nuwan/work/cloudlaunch-cli/venv/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/Nuwan/work/cloudlaunch-cli/venv/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/Users/Nuwan/work/cloudlaunch-cli/venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/Nuwan/work/cloudlaunch-cli/venv/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/Nuwan/work/cloudlaunch-cli/venv/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/Nuwan/work/cloudlaunch-cli/venv/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/Users/Nuwan/work/cloudlaunch-cli/cloudlaunch_cli/main.py", line 80, in list_deployments
    deployments = cloudlaunch_client.deployments.list(archived=archived)
  File "/Users/Nuwan/work/cloudlaunch-cli/cloudlaunch_cli/api/endpoints.py", line 100, in list
    return [self._create_response(item) for item in items['results']]
TypeError: string indices must be integer
@nuwang
Copy link
Contributor Author

nuwang commented Apr 6, 2018

@machristie I think I found the problem. The schema is listing endpoints incorrectly: https://launch.usegalaxy.org/cloudlaunch/api/v1/schema/
It's missing the /cloudlaunch bit, and has absolute paths to /api/v1/schema instead.

@machristie
Copy link
Collaborator

machristie commented Apr 6, 2018

That's odd because it works for me. I wonder if this is due to the authentication issue. Did you configure your API token?


I tried with an invalid API token but I get an Invalid token error, not your error.

That error message you are getting makes me think that there is no pagination: items['results'] is raising TypeError because 'results' isn't an integer. I'm not sure what would cause that.

@machristie
Copy link
Collaborator

You might try the following in the code to get more details on what is going over the wire:

from http.client import HTTPConnection
HTTPConnection.debuglevel = 1

import logging
# you need to initialize logging, otherwise you will not see anything from
# requests
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
requests_log = logging.getLogger("urllib3")
requests_log.setLevel(logging.DEBUG)
requests_log.propagate = True

@nuwang
Copy link
Contributor Author

nuwang commented Apr 6, 2018

This is an extract from https://launch.usegalaxy.org/cloudlaunch/api/v1/schema/:
Note the url for "applications":

            "url": "/api/v1/applications/",

Shouldn't it be:

            "url": "/cloudlaunch/api/v1/applications/",

This is the full extract:

HTTP 200 OK
Allow: GET, HEAD, OPTIONS
Content-Type: application/coreapi+json
Vary: Accept

{
    "_type": "document",
    "_meta": {
        "url": "http://launch.usegalaxy.org/cloudlaunch/api/v1/schema/",
        "title": "CloudLaunch API"
    },
    "applications": {
        "list": {
            "_type": "link",
            "url": "/api/v1/applications/",
            "action": "get",
            "description": "API endpoint that allows applications to be viewed or edited.",
            "fields": [
                {
                    "name": "page",
                    "location": "query",
                    "schema": {
                        "description": "A page number within the paginated result set.",
                        "title": "Page",
                        "_type": "integer"
                    }
                },

@nuwang
Copy link
Contributor Author

nuwang commented Apr 6, 2018

I ran this through a debugger, and the request is going to: http://launch.usegalaxy.org/api/v1/applications instead of http://launch.usegalaxy.org/cloudlaunch/api/v1/applications. Works fine on my local machine, since it doesn't have that cloudlaunch bit.

@machristie
Copy link
Collaborator

Oh I see. I was just testing locally.

@machristie
Copy link
Collaborator

This is an issue for launch.usegalaxy.org because its nginx config proxies /cloudlaunch to /, so the DRF SchemaGenerator doesn't take SCRIPT_NAME into account.

This is a known issue with DRF coreapi schema, see issue 5788. The supported way to resolve this is to supply the base URL to the get_schema_view method via the url argument.

I discussed this with @nuwang and we decided it makes sense to define this in settings.py based on an environment variable.

I think I'll create a separate issue in cloudlaunch since that is where it needs to be fixed.

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

No branches or pull requests

2 participants