Thursday, 2019-06-13

*** dbpiv has joined #ara00:37
*** dbpiv has quit IRC01:23
*** dbpiv has joined #ara01:40
*** dbpiv has quit IRC02:18
*** jparrill has quit IRC05:28
*** gvincent has quit IRC05:48
*** gvincent has joined #ara05:48
*** zbr|flow is now known as zbr|ooo06:11
*** herald85 has joined #ara07:09
*** sshnaidm has quit IRC11:52
*** sshnaidm has joined #ara11:56
*** dbpiv has joined #ara12:18
*** Jmainguy has quit IRC13:44
*** Jmainguy has joined #ara13:48
dmsimardapollo13: I looked a little bit more at the db router middleware things. Our use case doesn't match the expectation that all databases are configured before launching django :(14:10
dmsimardlike a lot of examples are about setting a write master, read replicas, etc14:10
apollo13yes, that's what I said :)14:10
apollo13we'd need a custom db backend14:10
*** Jmainguy has quit IRC14:11
dmsimardapollo13: it's not that I didn't trust you, it's that I'm learning how things work :p14:12
dmsimardI'll attempt to capture this in a github issue14:16
*** herald85 has quit IRC14:22
dmsimardapollo13: https://github.com/ansible-community/ara/issues/5714:53
*** Jmainguy has joined #ara15:53
*** sshnaidm is now known as sshnaidm|off16:04
*** Jmainguy has quit IRC16:30
*** Jmainguy has joined #ara16:31
*** pabelanger has joined #ara17:34
dmsimardpabelanger: I've been so far unable to reproduce the issue in both 0.x and 1.017:46
dmsimard0.x has integration tests that can run locally with run_tests.sh -- tried renaming one of the integration test playbooks with some accents and it didn't trigger17:47
dmsimardrunning full ansible integration tests against 1.0 with increased verbosity to get the full callback trace, might give a hint17:51
pabelangerdmsimard: yah, I plan to collect the database and store it for our jobs, but not sure when it will happen again. This was the first time I seen that failure in about 2 months of using ara17:52
*** etienne has joined #ara18:22
dmsimardapollo13: for that database router thing, could we just override get_connection_params ? https://github.com/django/django/blob/1564e42ad397021093585147875a21dae1a3b3fc/django/db/backends/sqlite3/base.py#L166-L19220:18
dmsimardand figure out the plumbing to get there20:19
apollo13yes, that or get_connection directly20:19
apollo13the question is, what aside from the database we need to patch to get the wanted functionality *gg*20:21
apollo13do we have to multiplex the API to all those paths?20:21
dmsimardapollo13: no20:23
dmsimardjust one database at a time but the location of the database is not known until the request comes in20:25
apollo13yes, but what does ara serve then?20:25
apollo13the database directly?20:25
apollo13I mean if you GET that URL what do you get?20:25
dmsimardyeah, as if configured normally20:25
dmsimardwould be the api server with data from that database20:26
apollo13but the api server doesn't directly serve from one url20:26
apollo13we have multiple endpoints20:26
apollo13couldn't the database file locations and endpoints clash if we have multiple nesting levels?20:26
dmsimardfor 0.x there is a webserver config that delegates everything under /ara-report/* to the wsgi app20:27
dmsimarddefine multiple nesting levels20:27
apollo13hu?20:28
dmsimardfor example openstack-ansible has different databases20:28
apollo13assume you have two database locations20:28
dmsimardfrom zuul http://logs.openstack.org/78/658178/1/check/openstack-ansible-deploy-aio_lxc-debian-stable/ad6fc29/ara-report/20:28
dmsimardfrom openstack-ansible: http://logs.openstack.org/78/658178/1/check/openstack-ansible-deploy-aio_lxc-debian-stable/ad6fc29/logs/ara-report/20:29
apollo13/ara-report/db1 and /ara-repor/db1/db220:29
dmsimardyeah there needs to be a convention20:29
apollo13like what? limited to one path segment?20:29
dmsimardthe convention in 0.x is there needs to be an ansible.sqlite file in the /ara-report/ directory20:29
dmsimardthat's also why you can download the database by hitting http://logs.openstack.org/78/658178/1/check/openstack-ansible-deploy-aio_lxc-debian-stable/ad6fc29/ara-report/ansible.sqlite20:30
dmsimardlet me pull up the webserver config, might make more sense20:30
apollo13sure, but how do you know that ansible.sqlite should serve the sqlite file and is not an API endpoint?20:30
apollo13or rather can you give me an example of how the URLs would look like20:30
dmsimardapollo13: http://paste.openstack.org/raw/752901/20:31
apollo13ie one ara server instance serving 2 databases20:31
apollo13dmsimard: right, but on ara 0.x you have just one URL which serves the whole frontend, right?20:31
dmsimardmeaning it replies with the webapp as opposed to an API ?20:32
apollo13yeah20:32
dmsimardright -- in our context instead of the webapp it'd be the API20:33
apollo13yeah but our API has then multiple suburls20:33
apollo13/plays, /files etc…20:33
dmsimardright so you'd have http://logs.openstack.org/78/658178/1/check/openstack-ansible-deploy-aio_lxc-debian-stable/ad6fc29/ara-report/api/v1/playbooks?name=foo20:33
apollo13at which point you have to make sure that we do not run into conflicts URL wise20:33
apollo13so basically what you are saying is search the url for "ara-report", take everything before as fs-path and everything afterwards as endpoint path for the api?20:34
dmsimardapollo13: the webserver config delegates everything under /ara-report/ so this works: http://logs.openstack.org/78/658178/1/check/openstack-ansible-deploy-aio_lxc-debian-stable/ad6fc29/logs/ara-report/result/c29919e1-1bf7-4017-8e3f-0df9ec705ec3/20:34
apollo13right20:34
apollo13looking at your webserver config though, what would happen if you have ara-report twice in the path :)20:35
apollo13or if we ever wanted to make ara-report and endpoint of the api20:35
dmsimardif you put ara-report twice in the path that's wrong :p20:35
apollo13that said, if you don't care about all that we might be able to handle it20:35
dmsimardthe scope needs to be narrow -- at least to begin with20:37
apollo13ok, so all we would need to do compared to the current setup is point to another settings file which has another ROOT_URLCONF which basically does include('<string>/ara-report', original_urls)20:37
apollo13and a middleware which copies that path into a thread_local + a db backend20:37
apollo13it might actually work ™20:37
* dmsimard looks up ROOT_URLCONF20:38
apollo13it's in the settings file and tells Django the entrypoint for routing20:38
apollo13or we could hack around that in a wsgi app20:39
apollo13so many options :D20:39
apollo13I guess both approaches might work20:40
apollo13I think rewriting the path and setting the threadlocal in a real wsgi app might be nicer20:41
dmsimardthe thing with get_connection_params is that it's not in the request context at all20:42
apollo13if we do it right we just have to rewrite script_name and path_info in the wsgi environment and django won't care20:42
apollo13hence a thread local20:42
dmsimardthat would be supplied by the middleware ?20:42
apollo13let me show you some pseudo code20:42
dmsimard<320:43
*** spiette has quit IRC20:43
*** spiette has joined #ara20:48
apollo13dmsimard: https://dpaste.de/5Jsx20:50
apollo13oh we can even set https://docs.djangoproject.com/en/2.2/ref/settings/#std:setting-WSGI_APPLICATION to point to that and return  django.core.wsgi.get_wsgi_application() instead of ara.server.wsgi.application20:52
apollo13this way all you need then is a settings file which has WSGI_APPLICATION set to this alternative one and we could probably default the default sqlite backend to our backend that falls back to the path in settings if the thread local isn't set20:52
apollo13+ a setting for a "root path" for the sqlite stuff, because you probably don't want to start looking in /20:53
apollo13(on the fs)20:53
apollo13does that make any sense?20:53
* dmsimard reads20:57
dmsimardapollo13: ok, so in terms of plumbing20:59
dmsimardIt means adding WSGI_APPLICATION to settings.py (which could be customized with settings.yaml?) -- set WSGI_APPLICATION to ara.server.other_wsgi which would be what you pasted21:03
dmsimardWe need to have a custom database backend which retrieves the path of the database based on the local thread storage21:03
apollo13yes, but we can use our custom database backend also instead of the normal sqlite backend21:04
dmsimardyou'd default to this new backend ?21:04
apollo13yes21:04
apollo13if we write it clever enough it can just fall back to the configured path from settings if there is nothing in the thread_local21:05
dmsimardI suppose it would be one less step for users to setup21:05
apollo13and we can even hide the actual WSGI_APPLICATION setting behind a boolean flag MASS_HOSTING?21:05
apollo13and then WSGI_APPLICATION = 'ara.server.some_other_wsgi' if MASS_HOSTING else django.core.wsgi21:06
apollo13we don't have to actually expose it I guess21:06
dmsimardI guess21:06
apollo13or make MASS_HOSTING a string which points to the base path from where you wanna start searching sqlite files21:07
apollo13I can't promise anything, but I'll give the wsgi stuff a try tomorrow21:07
apollo13and now I am going to bed I guess, it isn't long to midnight anymore :D21:07
dmsimardapollo13: I'm probably going to take a stab at it, will add you to a review if I send something21:08
apollo13cool!21:08
apollo13& good night21:08
dmsimardthanks for the help, have nice dreams :p21:08
*** etienne has quit IRC21:27
*** etienne has joined #ara21:28
*** harlowja has quit IRC22:47

Generated by irclog2html.py 2.15.3 by Marius Gedminas - find it at mg.pov.lt!