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 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/__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() 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/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 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