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
=== modified file 'Makefile'
--- Makefile 2016-07-05 04:39:30 +0000
+++ Makefile 2016-08-05 14:48:11 +0000
@@ -35,6 +35,11 @@
35export PYTHONPATH35export PYTHONPATH
36export DJANGO_SETTINGS_MODULE36export DJANGO_SETTINGS_MODULE
3737
38# talisker config
39DEBUGLOG ?= logs/sso.log
40export DEBUGLOG
41export DEVEL
42
38### Tarball ###43### Tarball ###
39$(TARBALL_BUILD_PATH): $(TARBALL_BUILD_DIR) tarball_exclude.txt cleanstatic collectstatic compilemessages-build44$(TARBALL_BUILD_PATH): $(TARBALL_BUILD_DIR) tarball_exclude.txt cleanstatic collectstatic compilemessages-build
40 @echo "Creating deployment tarball at $(TARBALL_BUILD_PATH)"45 @echo "Creating deployment tarball at $(TARBALL_BUILD_PATH)"
@@ -67,9 +72,10 @@
6772
68### Wheels ###73### Wheels ###
6974
70virtualenv:75virtualenv:
71 @virtualenv --clear --system-site-packages $(ENV)76 @virtualenv --clear --system-site-packages $(ENV)
7277
78
73update-wheels: ARGS=-r requirements.txt79update-wheels: ARGS=-r requirements.txt
74update-wheels: virtualenv80update-wheels: virtualenv
75 $(PIP) wheel -w $(WHEELS_DIR) -f $(WHEELS_DIR) $(ARGS)81 $(PIP) wheel -w $(WHEELS_DIR) -f $(WHEELS_DIR) $(ARGS)
@@ -157,7 +163,7 @@
157163
158run: ARGS=0.0.0.0:8000164run: ARGS=0.0.0.0:8000
159run: collectstatic django-check165run: collectstatic django-check
160 $(ENV)/bin/gunicorn django_project.wsgi:application --workers=2 --reload --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999 --error-logfile=- --access-logfile=-166 $(ENV)/bin/talisker django_project.wsgi:application --reload --workers=2 --pid=logs/gunicorn.pid --bind=$(ARGS) --timeout=99999 --access-logfile=-
161167
162start: bootstrap start-db168start: bootstrap start-db
163169
164170
=== modified file 'django_project/settings_base.py'
--- django_project/settings_base.py 2016-06-08 17:05:05 +0000
+++ django_project/settings_base.py 2016-08-05 14:48:11 +0000
@@ -323,52 +323,7 @@
323LOCALE_PATHS = [323LOCALE_PATHS = [
324 os.path.join(BASE_DIR, 'branches/translations/locale'),324 os.path.join(BASE_DIR, 'branches/translations/locale'),
325]325]
326LOGGING = {326LOGGING_CONFIG = None
327 'disable_existing_loggers': False,
328 'filters': {},
329 'formatters': {
330 'simple': {
331 'datefmt': None,
332 'format': '%(asctime)s %(levelname)s %(name)s %(message)s',
333 },
334 'verbose': {
335 'datefmt': None,
336 'format': ('%(asctime)s %(levelname)s %(module)s %(process)d '
337 '%(thread)d %(message)s'),
338 },
339 },
340 'handlers': {
341 'file': {
342 'filename': os.path.join(LOGS_DIR, 'sso.log'),
343 'formatter': 'simple',
344 'class': 'logging.FileHandler',
345 'filters': '',
346 'level': 'INFO',
347 },
348 },
349 'incremental': False,
350 'loggers': {
351 'sso': {
352 'level': 'INFO',
353 'propagate': False,
354 'filters': [],
355 'handlers': ['file'],
356 },
357 'django': {
358 'level': 'INFO',
359 'propagate': False,
360 'filters': [],
361 'handlers': ['file'],
362 },
363 },
364 'root': {
365 'level': 'INFO',
366 'filters': [],
367 'handlers': ['file'],
368 },
369 'version': 1,
370}
371LOGGING_CONFIG = 'django.utils.log.dictConfig'
372LOGIN_REDIRECT_URL = '/'327LOGIN_REDIRECT_URL = '/'
373LOGIN_URL = '/+login'328LOGIN_URL = '/+login'
374LOGOUT_URL = '/accounts/logout/'329LOGOUT_URL = '/accounts/logout/'
375330
=== modified file 'requirements.txt'
--- requirements.txt 2016-08-01 15:29:42 +0000
+++ requirements.txt 2016-08-05 14:48:11 +0000
@@ -1,3 +1,6 @@
1# talisker must go first, to ensure its versions of various dependencies are met.
2talisker==0.4.1
3
1bson==0.3.34bson==0.3.3
2canonical-raven==0.0.35canonical-raven==0.0.3
3cffi==1.6.06cffi==1.6.0
@@ -14,7 +17,6 @@
14enum34==1.1.517enum34==1.1.5
15gargoyle-yplan==1.2.518gargoyle-yplan==1.2.5
16gpgservice-client==0.0.1119gpgservice-client==0.0.11
17gunicorn==19.3.0
18idna==2.120idna==2.1
19ipaddress==1.0.1621ipaddress==1.0.16
20lazr.authentication==0.1.322lazr.authentication==0.1.3
@@ -34,7 +36,6 @@
34raven==5.6.036raven==5.6.0
35requests-oauthlib==0.4.237requests-oauthlib==0.4.2
36six==1.10.038six==1.10.0
37statsd==3.1
38testresources==0.2.739testresources==0.2.7
39timeline==0.0.440timeline==0.0.4
40timeline-django==0.0.441timeline-django==0.0.4
4142
=== modified file 'src/testing/runner.py'
--- src/testing/runner.py 2016-06-09 12:44:32 +0000
+++ src/testing/runner.py 2016-08-05 14:48:11 +0000
@@ -10,6 +10,7 @@
10from gargoyle import gargoyle10from gargoyle import gargoyle
11from olstests import suites11from olstests import suites
12from olstestsdjango import runner12from olstestsdjango import runner
13import talisker.logs
1314
14try:15try:
15 import cProfile as profile16 import cProfile as profile
@@ -26,6 +27,7 @@
26 """27 """
2728
28 def setUp(self):29 def setUp(self):
30 talisker.logs.configure_test_logging()
29 super(SSOTestSuite, self).setUp()31 super(SSOTestSuite, self).setUp()
30 # gargoyle caches settings. Setting timeout to 0 prevents this,32 # gargoyle caches settings. Setting timeout to 0 prevents this,
31 # increasing test isolation.33 # increasing test isolation.