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

mgr/dashboard: Implement a RGW proxy #21258

Merged
merged 3 commits into from Apr 11, 2018
Merged

mgr/dashboard: Implement a RGW proxy #21258

merged 3 commits into from Apr 11, 2018

Conversation

votdev
Copy link
Member

@votdev votdev commented Apr 5, 2018

Implement a RGW proxy which can be used by the frontend to talk to the RGW Admin Ops API.
This PR takes over #20799.

@LenzGr
Copy link
Contributor

LenzGr commented Apr 6, 2018

retest this please

@LenzGr
Copy link
Contributor

LenzGr commented Apr 6, 2018

I re-tested this on a local branch against the frontend PR proposed in #20869 and it worked as advertised.

except NoCredentialsException as e:
cherrypy.response.headers['Content-Type'] = 'application/json'
cherrypy.response.status = 401
return json.dumps({'message': str(e)})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line triggers an exception in cherrypy when running in python 3 because of the return type. Please change this line to:
return json.dumps({'message': str(e)}).encode('utf-8')

@sebastian-philipp
Copy link
Contributor

The proxy is sending the wrong content-type:

curl -v 'http://ubuntu:41079/api/rgw/proxy'  -H 'Cookie: session_id=2e248d6eee03b79da565d6cbc24f6451f7fcbceb'
*   Trying 127.0.1.1...
* TCP_NODELAY set
* Connected to ubuntu (127.0.1.1) port 41079 (#0)
> GET /api/rgw/proxy HTTP/1.1
> Host: ubuntu:41079
> User-Agent: curl/7.55.1
> Accept: */*
> Cookie: gsScrollPos-753=338; gsScrollPos-1388=0; gsScrollPos-1408=0; gsScrollPos-957=0; gsScrollPos-346=0; gsScrollPos-441=; session_id=2e248d6eee03b79da565d6cbc24f6451f7fcbceb
> 
< HTTP/1.1 405 Method Not Allowed
< Date: Fri, 06 Apr 2018 13:55:48 GMT
< Content-Length: 121
< Content-Type: text/html;charset=utf-8
< Server: CherryPy/3.5.0
< Set-Cookie: session_id=2e248d6eee03b79da565d6cbc24f6451f7fcbceb; Path=/
< 
* Connection #0 to host ubuntu left intact
{"Code":"MethodNotAllowed","RequestId":"tx00000000000000000000a-005ac77c64-d384-default","HostId":"d384-default-default"}% 

Copy link
Contributor

@sebastian-philipp sebastian-philipp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm except for the wrong content type.

return daemon


@ApiController('rgw/proxy')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the merge of #21239 the way we specify the controller paths has changed a bit. In #21239 description is an example of how to declare a controller that acts as a proxy. Please update this controller.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@votdev votdev changed the title mgr/dashboard: Implement a RGW proxy [WIP] mgr/dashboard: Implement a RGW proxy Apr 9, 2018
@votdev votdev added the DNM label Apr 9, 2018
@votdev votdev changed the title [WIP] mgr/dashboard: Implement a RGW proxy mgr/dashboard: Implement a RGW proxy Apr 9, 2018
@votdev votdev removed the DNM label Apr 9, 2018
@votdev
Copy link
Member Author

votdev commented Apr 9, 2018

@sebastian-philipp After adapting the RGW proxy controller to #21239 the endpoint 'rgw/proxy' does not exist anymore and you'll get an error message with correct content-type:

curl -v 'http://localhost:4200/api/rgw/proxy' -H 'Cookie: session_id=61ebba675d78ca85d1363159adcf7d360bdd463d'
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 4200 (#0)
> GET /api/rgw/proxy HTTP/1.1
> Host: localhost:4200
> User-Agent: curl/7.55.1
> Accept: */*
> Cookie: session_id=61ebba675d78ca85d1363159adcf7d360bdd463d
> 
< HTTP/1.1 404 Not Found
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< date: Mon, 09 Apr 2018 10:03:43 GMT
< content-length: 592
< content-type: application/json
< server: CherryPy/10.2.1
< connection: close
< 
* Closing connection 0
{"status": "404 Not Found", "version": "10.2.1", "detail": "The path '/api/rgw/proxy' was not found.", "traceback": "Traceback (most recent call last):\n  File \"/usr/lib/python2.7/site-packages/cherrypy/_cprequest.py\", line 670, in respond\n    response.body = self.handler()\n  File \"/usr/lib/python2.7/site-packages/cherrypy/lib/encoding.py\", line 221, in __call__\n    self.body = self.oldhandler(*args, **kwargs)\n  File \"/usr/lib/python2.7/site-packages/cherrypy/_cperror.py\", line 415, in __call__\n    raise self\nNotFound: (404, \"The path '/api/rgw/proxy' was not found.\")\n"}%                          

@votdev
Copy link
Member Author

votdev commented Apr 9, 2018

jenkins retest this please

@votdev votdev force-pushed the rgw_proxy branch 4 times, most recently from 5b1a60b to 6b0ce1c Compare April 9, 2018 12:42
@votdev votdev closed this Apr 9, 2018
@rjfd
Copy link
Contributor

rjfd commented Apr 10, 2018

QA tests failed: http://pulpito.ceph.com/rdias-2018-04-10_13:03:34-rados:mgr-wip-rdias-testing-distro-basic-mira/

Teuthology log: http://qa-proxy.ceph.com/teuthology/rdias-2018-04-10_13:03:34-rados:mgr-wip-rdias-testing-distro-basic-mira/2380150/teuthology.log

After some investigation with @p-na we found out that the current RGW backend code is assuming that there is alwasy an RGW daemon in the service map with svc_id == 'rgw', which is not always the case.

This is the output of the service map of the teuthology run:

2018-04-10T13:21:19.376 INFO:teuthology.orchestra.run.mira058.stdout:    "servicemap": {
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:        "epoch": 2,
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:        "modified": "2018-04-10 13:18:59.572961",
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:        "services": {
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:            "rgw": {
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:                "daemons": {
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:                    "summary": "",
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:                    "0": {
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:                        "start_epoch": 2,
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:                        "start_stamp": "2018-04-10 13:18:57.775002",
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:                        "gid": 4330,
2018-04-10T13:21:19.377 INFO:teuthology.orchestra.run.mira058.stdout:                        "addr": "172.21.6.134:0/4249917863",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                        "metadata": {
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "arch": "x86_64",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "ceph_release": "mimic",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "ceph_version": "ceph version 13.0.2-844-g0992565 (09925656755ace1be9a94ad4b5a821d985754788) mimic (dev)",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "ceph_version_short": "13.0.2-844-g0992565",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "cpu": "Intel(R) Xeon(R) CPU           X3440  @ 2.53GHz",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "distro": "ubuntu",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "distro_description": "Ubuntu 16.04.4 LTS",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "distro_version": "16.04",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "frontend_config#0": "civetweb port=7280",
2018-04-10T13:21:19.378 INFO:teuthology.orchestra.run.mira058.stdout:                            "frontend_type#0": "civetweb",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "hostname": "mira058",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "kernel_description": "#143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "kernel_version": "4.4.0-119-generic",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "mem_swap_kb": "0",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "mem_total_kb": "16422520",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "num_handles": "1",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "os": "Linux",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "pid": "13513",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "zone_id": "3312e42d-b57d-4303-a8bc-f10c88b0c1bf",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "zone_name": "default",
2018-04-10T13:21:19.379 INFO:teuthology.orchestra.run.mira058.stdout:                            "zonegroup_id": "c8429870-2040-41ad-9473-273a7aec37b6",
2018-04-10T13:21:19.380 INFO:teuthology.orchestra.run.mira058.stdout:                            "zonegroup_name": "default"
2018-04-10T13:21:19.380 INFO:teuthology.orchestra.run.mira058.stdout:                        }
2018-04-10T13:21:19.380 INFO:teuthology.orchestra.run.mira058.stdout:                    }
2018-04-10T13:21:19.380 INFO:teuthology.orchestra.run.mira058.stdout:                }
2018-04-10T13:21:19.380 INFO:teuthology.orchestra.run.mira058.stdout:            }
2018-04-10T13:21:19.380 INFO:teuthology.orchestra.run.mira058.stdout:        }
2018-04-10T13:21:19.380 INFO:teuthology.orchestra.run.mira058.stdout:    }

@votdev
Copy link
Member Author

votdev commented Apr 10, 2018

Just for documentation, the service map using vstart looks like

{
   'rgw':{
      'daemons':{
         'rgw':{
            'start_stamp':'2018-04-10 09:47:11.348433',
            'addr':'192.168.178.3:0/1119332116',
            'gid':4229            L,
            'start_epoch':2            L,
            'metadata':{
               'pid':'2609',
               'kernel_description':'#43-Ubuntu SMP Wed Mar 14 15:20:44 UTC 2018',
               'mem_swap_kb':'8268796',
               'zone_name':'default',
               'zonegroup_id':'50c375f1-82fa-47c9-8f4b-edc1dc6e7bec',
               'zonegroup_name':'default',
               'hostname':'arrakis',
               'distro_version':'20180406',
               'frontend_config#0':'civetweb port=8000',
               'ceph_release':'mimic',
               'num_handles':'1',
               'ceph_version':'ceph version 13.0.2-832-gee03866b9f (ee03866b9feaaca1af4c77287d14b9da6ea9c8cb) mimic (dev)',
               'distro':'opensuse',
               'arch':'x86_64',
               'distro_description':'openSUSE Tumbleweed',
               'zone_id':'45d63550-dd4d-4611-9faf-066251e300c5',
               'kernel_version':'4.13.0-38-generic',
               'mem_total_kb':'16306280',
               'frontend_type#0':'civetweb',
               'ceph_version_short':'13.0.2-832-gee03866b9f',
               'os':'Linux',
               'cpu':'Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz'
            }
         },
         'summary':''
      }
   }
}

@votdev votdev force-pushed the rgw_proxy branch 3 times, most recently from 3084293 to 68cb890 Compare April 10, 2018 18:16
@votdev
Copy link
Member Author

votdev commented Apr 10, 2018

@rjfd The _determine_rgw_addr function has been improved to fix the issue.

@votdev votdev force-pushed the rgw_proxy branch 2 times, most recently from ed9f228 to aac311d Compare April 11, 2018 06:21
@rjfd
Copy link
Contributor

rjfd commented Apr 11, 2018

p-se and others added 3 commits April 11, 2018 12:26
This commit will include the `python-requests-aws` [1] library.  This library
extends the `requests` library by an authentication mechanism to S3 gateways.

[1] https://github.com/tax/python-requests-aws

Signed-off-by: Patrick Nawracay <pnawracay@suse.com>
This implementation is basically a Rados Gateway reverse proxy.  It
additionally takes care of the authentication to the Rados Gateway, but to use
it you will have to be authenticated against the dashboards RESTful API.

The corresponding credentials can be configured using the following commands:

    dashboard set-rgw-api-secret-key <secret-key>

    dashboard set-rgw-api-access-key <access-key>

Signed-off-by: Patrick Nawracay <pnawracay@suse.com>
Signed-off-by: Volker Theile <vtheile@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants