Merge lp:~bloodearnest/canonical-identity-provider/talisker into lp:canonical-identity-provider/release

Proposed by Simon Davy
Status: Rejected
Rejected by: Simon Davy
Proposed branch: lp:~bloodearnest/canonical-identity-provider/talisker
Merge into: lp:canonical-identity-provider/release
Diff against target: 141 lines (+14/-50)
4 files modified
Makefile (+8/-2)
django_project/settings_base.py (+1/-46)
requirements.txt (+3/-2)
src/testing/runner.py (+2/-0)
To merge this branch: bzr merge lp:~bloodearnest/canonical-identity-provider/talisker
Reviewer Review Type Date Requested Status
Ricardo Kirkner (community) Approve
Review via email: mp+297455@code.launchpad.net

Commit message

Add talisker, and remove explicit logging config, using the talisker logging configuration insteasd. Some dependencies now managed by talisker.

Description of the change

Add talisker, and remove explicit logging config. Some dependencies now managed by talisker.

The goal of talisker, in this instance
 - standard logging format
 - standard logging config (e.g. stderr)
 - standardise some cross app common dependencies

The idea is to remove app-specific config for base log output, allowing easier control of logging across projects.

In terms of usage, there's some subtle changes to logging in development

Previously:

make run:
  - gunicorn access and error logs to console
  - sso/django logs to ./logs/sso.log
make test:
  - sso/django logs to ./logs/sso.log
  - all else to console (warnings, etc)

Now:

make run: all logs, including warnings, w/same format, to console. Nothing to disk

make test: null handler, no log output by default, but logging still works properly. Individual testcases can still use in-memory log handlers to capture log messages for assertion.

Comments welcome.

To post a comment you must log in.
Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

+1 to logging to console (one of the 12-factor app tenants) as it makes the application more portable (environment independence)

Revision history for this message
Simon Davy (bloodearnest) wrote :

On Mon, Jul 11, 2016 at 3:57 PM, Ricardo Kirkner
<email address hidden> wrote:
> +1 to logging to console (one of the 12-factor app tenants) as it makes the application more portable (environment independence)
>
> Diff comments:
>
>>
>> === modified file 'requirements.txt'
>> --- requirements.txt 2016-07-03 22:36:48 +0000
>> +++ requirements.txt 2016-07-06 16:05:45 +0000
>> @@ -34,7 +36,6 @@
>> raven==5.6.0
>> requests-oauthlib==0.4.2
>> six==1.10.0
>> -statsd==3.1
>
> why is this removed?

Because talsisker brings it in as a dep (and upgrades it in the process)

The idea was to provide one place for our core cross-app deps to be
versioned/pulled from. Makes it easier to ensure we are on the same
versions across apps, and reduces the number of deps the app itself
has to version/manage.

At the moment, that's

gunicorn
statsd
requests

Make sense?

>> testresources==0.2.7
>> timeline==0.0.4
>> timeline-django==0.0.4
>
>
> --
> https://code.launchpad.net/~bloodearnest/canonical-identity-provider/talisker/+merge/297455
> You are the owner of lp:~bloodearnest/canonical-identity-provider/talisker.

Revision history for this message
Ricardo Kirkner (ricardokirkner) wrote :

> On Mon, Jul 11, 2016 at 3:57 PM, Ricardo Kirkner
> <email address hidden> wrote:
> > +1 to logging to console (one of the 12-factor app tenants) as it makes the
> application more portable (environment independence)
> >
> > Diff comments:
> >
> >>
> >> === modified file 'requirements.txt'
> >> --- requirements.txt 2016-07-03 22:36:48 +0000
> >> +++ requirements.txt 2016-07-06 16:05:45 +0000
> >> @@ -34,7 +36,6 @@
> >> raven==5.6.0
> >> requests-oauthlib==0.4.2
> >> six==1.10.0
> >> -statsd==3.1
> >
> > why is this removed?
>
> Because talsisker brings it in as a dep (and upgrades it in the process)
>
> The idea was to provide one place for our core cross-app deps to be
> versioned/pulled from. Makes it easier to ensure we are on the same
> versions across apps, and reduces the number of deps the app itself
> has to version/manage.
>
> At the moment, that's
>
> gunicorn
> statsd
> requests
>
> Make sense?

At some level, yes, but then it seems odd to rely on the implicit dependency when the code depends on the library explicitly. Also, it means that if for any reason we need to bump these lib's versions we will have to bump talisker first (for no real reason).

>
> >> testresources==0.2.7
> >> timeline==0.0.4
> >> timeline-django==0.0.4
> >
> >
> > --
> > https://code.launchpad.net/~bloodearnest/canonical-identity-
> provider/talisker/+merge/297455
> > You are the owner of lp:~bloodearnest/canonical-identity-provider/talisker.

Revision history for this message
Ricardo Kirkner (ricardokirkner) :
review: Approve
Revision history for this message
Simon Davy (bloodearnest) wrote :

On Mon, Jul 11, 2016 at 4:08 PM, Ricardo Kirkner
<email address hidden> wrote:
>> On Mon, Jul 11, 2016 at 3:57 PM, Ricardo Kirkner
>> <email address hidden> wrote:
>> > +1 to logging to console (one of the 12-factor app tenants) as it makes the
>> application more portable (environment independence)
>> >
>> > Diff comments:
>> >
>> >>
>> >> === modified file 'requirements.txt'
>> >> --- requirements.txt 2016-07-03 22:36:48 +0000
>> >> +++ requirements.txt 2016-07-06 16:05:45 +0000
>> >> @@ -34,7 +36,6 @@
>> >> raven==5.6.0
>> >> requests-oauthlib==0.4.2
>> >> six==1.10.0
>> >> -statsd==3.1
>> >
>> > why is this removed?
>>
>> Because talsisker brings it in as a dep (and upgrades it in the process)
>>
>> The idea was to provide one place for our core cross-app deps to be
>> versioned/pulled from. Makes it easier to ensure we are on the same
>> versions across apps, and reduces the number of deps the app itself
>> has to version/manage.
>>
>> At the moment, that's
>>
>> gunicorn
>> statsd
>> requests
>>
>> Make sense?
>
> At some level, yes, but then it seems odd to rely on the implicit dependency when the code depends on the library explicitly.

Perhaps, but keeping a consistent version of gunicorn across services,
for example, is worth it, IMO. Statsd, perhaps not. But talisker
depends on statsd anyway. And in future, I hope that apps will get a
statsd instance via talisker's helper functions, rather than importing
it directly, thus decoupling some more.

Do we currently explicitly pin all our deps' deps currently? If so,
perhaps we should here too, but see below for the caveat.

> Also, it means that if for any reason we need to bump these lib's versions we will have to bump talisker first (for no real reason).

Actually, due to how pip works, we don't need to bump talisker here.
Pip's doesn't have full dependency resolution, it just uses the first
version it finds. Yes, this sucks, and it's why talisker appears first
in the requirements.txt.

But, we can (ab)use this - if we needed to bump statsd or similar,
we'd just put the statsd version pin *before* the talisker line, and
we should be good to go.

So, this bundling of a few key deps version in talisker is just an
idea, but I accept it might not be the best approach. But there are
some minimum versions (e.g we need gunicorn 19.5 for some bug fixes we
upstreamed relating to statsd support with custom logging).

1474. By Simon Davy

update to talisker 0.4.0

1475. By Simon Davy

bump talisker to 0.4.1

Unmerged revisions

1475. By Simon Davy

bump talisker to 0.4.1

1474. By Simon Davy

update to talisker 0.4.0

1473. By Simon Davy

merging, plus talisker tweak

1472. By Simon Davy

remove comment

1471. By Simon Davy

merge

1470. By Simon Davy

log to file for test runs

1469. By Simon Davy

merging

1468. By Simon Davy

add talisker

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2016-07-05 04:39:30 +0000
3+++ Makefile 2016-08-05 14:48:11 +0000
4@@ -35,6 +35,11 @@
5 export PYTHONPATH
6 export DJANGO_SETTINGS_MODULE
7
8+# talisker config
9+DEBUGLOG ?= logs/sso.log
10+export DEBUGLOG
11+export DEVEL
12+
13 ### Tarball ###
14 $(TARBALL_BUILD_PATH): $(TARBALL_BUILD_DIR) tarball_exclude.txt cleanstatic collectstatic compilemessages-build
15 @echo "Creating deployment tarball at $(TARBALL_BUILD_PATH)"
16@@ -67,9 +72,10 @@
17
18 ### Wheels ###
19
20-virtualenv:
21+virtualenv:
22 @virtualenv --clear --system-site-packages $(ENV)
23
24+
25 update-wheels: ARGS=-r requirements.txt
26 update-wheels: virtualenv
27 $(PIP) wheel -w $(WHEELS_DIR) -f $(WHEELS_DIR) $(ARGS)
28@@ -157,7 +163,7 @@
29
30 run: ARGS=0.0.0.0:8000
31 run: collectstatic django-check
32- $(ENV)/bin/gunicorn django_project.wsgi:application --workers=2 --reload --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999 --error-logfile=- --access-logfile=-
33+ $(ENV)/bin/talisker django_project.wsgi:application --reload --workers=2 --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999 --access-logfile=-
34
35 start: bootstrap start-db
36
37
38=== modified file 'django_project/settings_base.py'
39--- django_project/settings_base.py 2016-06-08 17:05:05 +0000
40+++ django_project/settings_base.py 2016-08-05 14:48:11 +0000
41@@ -323,52 +323,7 @@
42 LOCALE_PATHS = [
43 os.path.join(BASE_DIR, 'branches/translations/locale'),
44 ]
45-LOGGING = {
46- 'disable_existing_loggers': False,
47- 'filters': {},
48- 'formatters': {
49- 'simple': {
50- 'datefmt': None,
51- 'format': '%(asctime)s %(levelname)s %(name)s %(message)s',
52- },
53- 'verbose': {
54- 'datefmt': None,
55- 'format': ('%(asctime)s %(levelname)s %(module)s %(process)d '
56- '%(thread)d %(message)s'),
57- },
58- },
59- 'handlers': {
60- 'file': {
61- 'filename': os.path.join(LOGS_DIR, 'sso.log'),
62- 'formatter': 'simple',
63- 'class': 'logging.FileHandler',
64- 'filters': '',
65- 'level': 'INFO',
66- },
67- },
68- 'incremental': False,
69- 'loggers': {
70- 'sso': {
71- 'level': 'INFO',
72- 'propagate': False,
73- 'filters': [],
74- 'handlers': ['file'],
75- },
76- 'django': {
77- 'level': 'INFO',
78- 'propagate': False,
79- 'filters': [],
80- 'handlers': ['file'],
81- },
82- },
83- 'root': {
84- 'level': 'INFO',
85- 'filters': [],
86- 'handlers': ['file'],
87- },
88- 'version': 1,
89-}
90-LOGGING_CONFIG = 'django.utils.log.dictConfig'
91+LOGGING_CONFIG = None
92 LOGIN_REDIRECT_URL = '/'
93 LOGIN_URL = '/+login'
94 LOGOUT_URL = '/accounts/logout/'
95
96=== modified file 'requirements.txt'
97--- requirements.txt 2016-08-01 15:29:42 +0000
98+++ requirements.txt 2016-08-05 14:48:11 +0000
99@@ -1,3 +1,6 @@
100+# talisker must go first, to ensure its versions of various dependencies are met.
101+talisker==0.4.1
102+
103 bson==0.3.3
104 canonical-raven==0.0.3
105 cffi==1.6.0
106@@ -14,7 +17,6 @@
107 enum34==1.1.5
108 gargoyle-yplan==1.2.5
109 gpgservice-client==0.0.11
110-gunicorn==19.3.0
111 idna==2.1
112 ipaddress==1.0.16
113 lazr.authentication==0.1.3
114@@ -34,7 +36,6 @@
115 raven==5.6.0
116 requests-oauthlib==0.4.2
117 six==1.10.0
118-statsd==3.1
119 testresources==0.2.7
120 timeline==0.0.4
121 timeline-django==0.0.4
122
123=== modified file 'src/testing/runner.py'
124--- src/testing/runner.py 2016-06-09 12:44:32 +0000
125+++ src/testing/runner.py 2016-08-05 14:48:11 +0000
126@@ -10,6 +10,7 @@
127 from gargoyle import gargoyle
128 from olstests import suites
129 from olstestsdjango import runner
130+import talisker.logs
131
132 try:
133 import cProfile as profile
134@@ -26,6 +27,7 @@
135 """
136
137 def setUp(self):
138+ talisker.logs.configure_test_logging()
139 super(SSOTestSuite, self).setUp()
140 # gargoyle caches settings. Setting timeout to 0 prevents this,
141 # increasing test isolation.