From f31101882391aa37bc6fdeb71d1559d5dcdfd4e7 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 14 Feb 2019 17:10:36 +0000 Subject: [PATCH 1/3] Fix errors in acme provisioning (#4648) * Better logging for errors on startup * Fix "TypeError: '>' not supported" when starting without an existing certificate * Fix a bug where an existing certificate would be reprovisoned every day --- changelog.d/4648.bugfix | 2 ++ synapse/app/homeserver.py | 19 +++++++++++++------ synapse/config/logger.py | 2 ++ 3 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 changelog.d/4648.bugfix diff --git a/changelog.d/4648.bugfix b/changelog.d/4648.bugfix new file mode 100644 index 000000000..bd117e866 --- /dev/null +++ b/changelog.d/4648.bugfix @@ -0,0 +1,2 @@ +Fix "TypeError: '>' not supported" when starting without an existing certificate. +Fix a bug where an existing certificate would be reprovisoned every day. diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py index dbd9a8387..05a97979e 100755 --- a/synapse/app/homeserver.py +++ b/synapse/app/homeserver.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2014-2016 OpenMarket Ltd +# Copyright 2019 New Vector Ltd # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,11 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +from __future__ import print_function + import gc import logging import os import sys -import traceback from six import iteritems @@ -27,6 +29,7 @@ from prometheus_client import Gauge from twisted.application import service from twisted.internet import defer, reactor +from twisted.python.failure import Failure from twisted.web.resource import EncodingResourceWrapper, NoResource from twisted.web.server import GzipEncoderFactory from twisted.web.static import File @@ -394,10 +397,10 @@ def setup(config_options): # is less than our re-registration threshold. provision = False - if (cert_days_remaining is None): - provision = True - - if cert_days_remaining > hs.config.acme_reprovision_threshold: + if ( + cert_days_remaining is None or + cert_days_remaining < hs.config.acme_reprovision_threshold + ): provision = True if provision: @@ -438,7 +441,11 @@ def setup(config_options): hs.get_datastore().start_doing_background_updates() except Exception: # Print the exception and bail out. - traceback.print_exc(file=sys.stderr) + print("Error during startup:", file=sys.stderr) + + # this gives better tracebacks than traceback.print_exc() + Failure().printTraceback(file=sys.stderr) + if reactor.running: reactor.stop() sys.exit(1) diff --git a/synapse/config/logger.py b/synapse/config/logger.py index 4b938053f..9b5994d55 100644 --- a/synapse/config/logger.py +++ b/synapse/config/logger.py @@ -242,3 +242,5 @@ def setup_logging(config, use_worker_options=False): [_log], redirectStandardIO=not config.no_redirect_stdio, ) + if not config.no_redirect_stdio: + print("Redirected stdout/stderr to logs") From f595d6ac577696744e56da3429a53b2a0eb1d952 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 14 Feb 2019 17:20:02 +0000 Subject: [PATCH 2/3] 0.99.1.1 --- CHANGES.md | 10 ++++++++++ changelog.d/4648.bugfix | 2 -- debian/changelog | 6 ++++++ synapse/__init__.py | 2 +- 4 files changed, 17 insertions(+), 3 deletions(-) delete mode 100644 changelog.d/4648.bugfix diff --git a/CHANGES.md b/CHANGES.md index 872ac440b..f1a9d58e4 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,13 @@ +Synapse 0.99.1.1 (2019-02-14) +============================= + +Bugfixes +-------- + +- Fix "TypeError: '>' not supported" when starting without an existing certificate. + Fix a bug where an existing certificate would be reprovisoned every day. ([\#4648](https://github.com/matrix-org/synapse/issues/4648)) + + Synapse 0.99.1 (2019-02-14) =========================== diff --git a/changelog.d/4648.bugfix b/changelog.d/4648.bugfix deleted file mode 100644 index bd117e866..000000000 --- a/changelog.d/4648.bugfix +++ /dev/null @@ -1,2 +0,0 @@ -Fix "TypeError: '>' not supported" when starting without an existing certificate. -Fix a bug where an existing certificate would be reprovisoned every day. diff --git a/debian/changelog b/debian/changelog index bc1ba153e..124128920 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +matrix-synapse-py3 (0.99.1.1) stable; urgency=medium + + * New synapse release 0.99.1.1 + + -- Synapse Packaging team Thu, 14 Feb 2019 17:19:44 +0000 + matrix-synapse-py3 (0.99.1) stable; urgency=medium [ Damjan Georgievski ] diff --git a/synapse/__init__.py b/synapse/__init__.py index f7bac0ea4..2004375f9 100644 --- a/synapse/__init__.py +++ b/synapse/__init__.py @@ -27,4 +27,4 @@ try: except ImportError: pass -__version__ = "0.99.1" +__version__ = "0.99.1.1" From 649fe1c2be69676ffd73c9ad1807ea0bc747b003 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Thu, 14 Feb 2019 17:29:40 +0000 Subject: [PATCH 3/3] Fix debian build dockerfile Make sure it refreshes the apt cache before trying to install stuff --- docker/Dockerfile-dhvirtualenv | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile-dhvirtualenv b/docker/Dockerfile-dhvirtualenv index ab28e4929..224c92352 100644 --- a/docker/Dockerfile-dhvirtualenv +++ b/docker/Dockerfile-dhvirtualenv @@ -58,7 +58,11 @@ RUN apt-get update -qq -o Acquire::Languages=none \ sqlite3 COPY --from=builder /dh-virtualenv_1.1-1_all.deb / -RUN apt-get install -yq /dh-virtualenv_1.1-1_all.deb + +# install dhvirtualenv. Update the apt cache again first, in case we got a +# cached cache from docker the first time. +RUN apt-get update -qq -o Acquire::Languages=none \ + && apt-get install -yq /dh-virtualenv_1.1-1_all.deb WORKDIR /synapse/source ENTRYPOINT ["bash","/synapse/source/docker/build_debian.sh"]