From e625831fa28cc3be4dcec07284f88907bf83cc30 Mon Sep 17 00:00:00 2001 From: Sukrit Khera Date: Mon, 20 Jun 2016 01:56:49 -0700 Subject: [PATCH 1/4] Fix CoreOS 1010.5 upgrade (uwsgi kernel issue) Fix CoreOS 1010.5 upgrade (uwsgi kernel issue) --- requirements.txt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/requirements.txt b/requirements.txt index e3dcd75..65af754 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,9 +2,7 @@ Flask==0.10.1 Flask-Cors==2.1.2 pymongo==3.2.2 gevent==1.1.1 -# Uncomment below , when 2.0.13 is released See https://github.com/gliderlabs/docker-alpine/issues/158#issuecomment-205401343 -# uWSGI==2.0.13 -https://github.com/unbit/uwsgi/archive/uwsgi-2.0.zip#egg=uwsgi +uWSGI==2.0.13.1 python-etcd==0.3.2 future==0.15.2 pytz==2016.3 From 795d76074b0d8336ebe29b3816186732d29c0cd2 Mon Sep 17 00:00:00 2001 From: Sukrit Khera Date: Mon, 20 Jun 2016 02:29:42 -0700 Subject: [PATCH 2/4] Update to next dev version --- deployer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployer/__init__.py b/deployer/__init__.py index 753de3a..f295488 100644 --- a/deployer/__init__.py +++ b/deployer/__init__.py @@ -3,7 +3,7 @@ from celery.signals import setup_logging -__version__ = '0.5.0' +__version__ = '0.5.1' __author__ = 'sukrit' deployer.logger.init_logging() From 10b5ae7b7fcb3faba21dcb483f8c2fea1383c94a Mon Sep 17 00:00:00 2001 From: Sukrit Khera Date: Mon, 20 Jun 2016 02:46:22 -0700 Subject: [PATCH 3/4] Add missing libffi library Add missing libffi library --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index adb2552..eeb2865 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,7 @@ RUN apk add --no-cache --update \ gettext \ curl \ openssl \ + libffi \ openssh-client \ # Etcdctl From edf5aa7da5ce1506178449a989423c3b210722c6 Mon Sep 17 00:00:00 2001 From: Sukrit Khera Date: Wed, 22 Jun 2016 10:21:26 -0700 Subject: [PATCH 4/4] Fix deployer indexes --- conf/appconfig.py | 3 +++ deployer/services/storage/mongo.py | 10 ++++++++-- tests/integration/services/storage/test_mongo.py | 3 +++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/conf/appconfig.py b/conf/appconfig.py index 4cb7f21..4e98700 100644 --- a/conf/appconfig.py +++ b/conf/appconfig.py @@ -298,3 +298,6 @@ DEFAULT_DEPLOYMENT_EXPIRY_SECONDS = 4 * 7 * 24 * 3600 # 4 weeks DEPLOYMENT_EXPIRY_SECONDS = int( os.getenv('DEPLOYMENT_EXPIRY_SECONDS', DEFAULT_DEPLOYMENT_EXPIRY_SECONDS)) +DEFAULT_EVENT_EXPIRY_SECONDS = 365 * 24 * 3600 # 1 year +EVENT_EXPIRY_SECONDS = int( + os.getenv('EVENT_EXPIRY_SECONDS', DEFAULT_EVENT_EXPIRY_SECONDS)) diff --git a/deployer/services/storage/mongo.py b/deployer/services/storage/mongo.py index 35a4a32..07f6b48 100644 --- a/deployer/services/storage/mongo.py +++ b/deployer/services/storage/mongo.py @@ -4,7 +4,8 @@ import pytz from conf.appconfig import MONGODB_URL, MONGODB_DEPLOYMENT_COLLECTION, \ MONGODB_DB, DEPLOYMENT_EXPIRY_SECONDS, MONGODB_EVENT_COLLECTION, \ - DEPLOYMENT_STATE_PROMOTED, RUNNING_DEPLOYMENT_STATES, CLUSTER_NAME + DEPLOYMENT_STATE_PROMOTED, RUNNING_DEPLOYMENT_STATES, CLUSTER_NAME, \ + EVENT_EXPIRY_SECONDS from deployer.services.storage.base import AbstractStore __author__ = 'sukrit' @@ -45,7 +46,6 @@ def setup(self): :return: """ idxs = self._deployments.index_information() - self._deployments.drop_indexes() if 'created_idx' not in idxs: self._deployments.create_index( [('cluster', pymongo.ASCENDING), @@ -69,6 +69,12 @@ def setup(self): ], name='app_idx') + event_idxs = self._events.index_information() + if 'expiry_idx' not in event_idxs: + self._events.create_index( + [('_expiry', pymongo.DESCENDING)], name='expiry_idx', + background=True, expireAfterSeconds=EVENT_EXPIRY_SECONDS) + @property def _db(self): return self.client[self.dbname] diff --git a/tests/integration/services/storage/test_mongo.py b/tests/integration/services/storage/test_mongo.py index f04aacf..32a7e74 100644 --- a/tests/integration/services/storage/test_mongo.py +++ b/tests/integration/services/storage/test_mongo.py @@ -120,12 +120,15 @@ def test_store_setup(self): # When I get the index informatiom # Note: Setup was already called indexes = self.store._deployments.index_information() + event_indexes = self.store._events.index_information() # Indexes are created as expected for idx in ('created_idx', 'identity_idx', 'app_idx', 'expiry_idx'): ok_(idx in indexes, '{} was not created'.format(idx)) + ok_('expiry_idx' in event_indexes, 'Event expiry_idx was not created') + def test_get_deployment(self): # When I get existing deployment