Tuesday, 2019-06-11

*** sshnaidm has quit IRC01:33
*** sshnaidm has joined #ara01:35
*** herald85 has joined #ara07:08
*** apollo13 has quit IRC08:36
*** apollo13 has joined #ara08:39
*** herald85 has quit IRC09:06
*** herald85 has joined #ara10:50
*** gvincent has quit IRC12:01
*** dbpiv has joined #ara12:41
*** zbr|ruck is now known as zbr|rover12:44
*** herald85 has quit IRC15:36
dmsimardapollo13: django question19:16
apollo13shoot I am fighting go19:16
dmsimardin ara 0.x we have a "special" wsgi app: https://ara.readthedocs.io/en/stable-0.x/advanced.html19:16
dmsimardThis is what makes us able to upload ansible.sqlite as artifact in the job logs and make this work: http://logs.openstack.org/29/664129/1/check/ansible-role-ara-tests-fedora-2.7/a5278f6/ara-report/19:17
dmsimardtl;dr, it maps "29/664129/1/check/ansible-role-ara-tests-fedora-2.7/a5278f6/ara-report/" to /some/logserver/path/29/664129/1/check/ansible-role-ara-tests-fedora-2.7/a5278f6/ara-report/ and defines ARA_DATABASE as /some/logserver/path/29/664129/1/check/ansible-role-ara-tests-fedora-2.7/a5278f6/ara-report/ansible.sqlite19:18
dmsimardit's a bit hacky and was designed to work with the flask backend: https://github.com/ansible-community/ara/blob/stable/0.x/ara/wsgi_sqlite.py19:19
apollo13I see19:19
dmsimardWe had to do this because 1) html generation didn't scale (way too many small files) and 2) because openstack runs >1 million playbooks per month19:20
dmsimardWe have an additional challenge in 1.0 where ara-web is decoupled and expects an API endpoint19:20
dmsimardwhereas in 0.x, the web app was bundled19:20
dmsimardI've been searching how we might end up implementing something similar with django but my google fu has been failing me19:22
apollo13so yes, you can always write your own wsgi middleware which calls settings.configure() appropriately19:23
apollo13https://docs.djangoproject.com/en/2.2/topics/settings/#django.conf.settings.configure19:23
apollo13actually no19:23
apollo13it will break your neck if you have more than one database file19:23
dmsimardapollo13: it would only ever be one database file, though19:25
dmsimardjust different (dynamic?) files based on the requested path19:25
apollo13yeah, but you can just configure django once19:25
apollo13inside one process19:25
dmsimardapollo13: so a wsgi app that fires django with the right settings ?19:27
apollo13no chance19:27
apollo13you can only fire it up once19:27
apollo13ie for one path19:27
apollo13after that django is configured and won't like you if you try to tell it to use a different database19:28
dmsimardso it would need to be different instances of django eh19:29
apollo13and different instances of django means actual different unix processes19:29
dmsimardapollo13: a custom database engine that extends the sqlite backend to use an arbitrary database post-settings ?19:33
dmsimard(I'm spouting nonsense but trying to come up with ideas)19:34
apollo13will probably work, but you need to put the location in a thread local and be very careful19:34
dmsimardIs the problem is that once settings.py is loaded, it's game over ?19:34
apollo13django has global state, there can only be one django per process19:35
apollo13and yes settings are just configured once19:35
dmsimardright, so really what we need is a way to load an arbitrary database location after settings have loaded19:35
apollo13which would mean a custom db backend and a middleware which puts all that stuff into thread locals and very very careful configuration because django usually keeps the connection open19:36
apollo13note: you are steering into completly unsupported waters19:37
dmsimard:D19:38
dmsimardneed to pick up kids from school, brb19:38
dmsimardapollo13: yeah I ideally don't want to swim in unsupported waters -- trying to think outside the box19:57
dmsimarda centralized database like postgre or mysql makes sense for some use cases19:58
dmsimardthe scale at which openstack runs on is a bit much though -- the "one database per job" approach of the sqlite middleware feels like a good fit20:01
dmsimardespecially in the context of CI jobs20:03
apollo13I guess it would be doable20:24
apollo13just not supported in any way20:24
apollo13I guess I might try writing such a database backend tomorrow, sounds like fun20:28
*** dbpiv has quit IRC20:46
dmsimardapollo13: found this old snippet that might be worth a try https://djangosnippets.org/snippets/2037/20:47
apollo13dmsimard: not really, a db router would require that we configure all the databases in settings.py20:47
apollo13but yeah, the middleware part is similar to what I imagine20:47
dmsimardthere was this thing as well: https://stackoverflow.com/a/1444256920:48
apollo13that sounds crazy :D20:48
apollo13but probably doable20:48
apollo13although I'd have to check if altering .databases there is threadsafe20:49
apollo13yeah no, .databases is not thread local20:52
apollo13typical SO post, nice in theory but completly flawed20:52
dmsimard:D20:52
*** njt has quit IRC21:33
*** njt has joined #ara21:33

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