Skip to content

Commit

Permalink
Merge pull request #31 from totem/develop
Browse files Browse the repository at this point in the history
0.3.5 Release
  • Loading branch information
sukrit007 committed Aug 14, 2015
2 parents 15078c5 + e370076 commit 756a322
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 16 deletions.
4 changes: 3 additions & 1 deletion conf/appconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
}
}

DEFAULT_STOP_TIMEOUT = '30s'

DEPLOYMENT_DEFAULTS = {
DEPLOYMENT_TYPE_GIT_QUAY: {
'deployment': {
Expand Down Expand Up @@ -134,7 +136,7 @@
'timeout': '10s'
},
'stop': {
'timeout': '30s',
'timeout': DEFAULT_STOP_TIMEOUT,
'check-retries':
TASK_SETTINGS['DEFAULT_DEPLOYMENT_STOP_CHECK_RETRIES']
}
Expand Down
2 changes: 1 addition & 1 deletion deployer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from celery.signals import setup_logging


__version__ = '0.3.3'
__version__ = '0.3.5'
__author__ = 'sukrit'

deployer.logger.init_logging()
Expand Down
7 changes: 6 additions & 1 deletion deployer/tasks/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def delete(name, version=None):
return _using_lock.si(
search_params, name,
do_task=(
_fleet_stop.si(name, version=version) |
_wait_for_stop.si(name, version=version,
search_params=search_params) |
_fleet_undeploy.si(name, version) |
_wait_for_undeploy.si(name, version, search_params=search_params)
)
Expand Down Expand Up @@ -607,6 +610,8 @@ def _pre_create_undeploy(deployment, search_params, next_task=None):
return next_task.delay() if next_task else None
name = deployment['deployment']['name']
undeploy_chain = [
_fleet_stop.si(name, version=version) |
_wait_for_stop.si(name, version=version, search_params=search_params) |
_fleet_undeploy.si(name, version, ignore_error=False),
_wait_for_undeploy.si(name, version, search_params=search_params)
]
Expand Down Expand Up @@ -656,7 +661,7 @@ def _fleet_stop(self, name, version=None, exclude_version=None,
:return: ret_value
"""
try:
stop(get_fleet_provider(), name, version,
stop(get_fleet_provider(), name, version=version,
exclude_version=exclude_version)
except RETRYABLE_FLEET_EXCEPTIONS as exc:
raise self.retry(exc=exc, max_retries=TASK_SETTINGS['SSH_RETRIES'],
Expand Down
2 changes: 1 addition & 1 deletion schemas/app-version-v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"timeout": {
"type": "string",
"description": "Deployment stop timeout represented in terms of seconds or minutes. e.g: 30s for timeout of 30 seconds. The application will be sent SIGTERM signal and will have this time for its cleanup.",
"default": "30s"
"default": "120s"
},
"check-retries": {
"type": "number",
Expand Down
36 changes: 24 additions & 12 deletions tests/unit/tasks/test_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from conf.appconfig import DEPLOYMENT_MODE_BLUEGREEN, \
DEPLOYMENT_MODE_REDGREEN, DEPLOYMENT_STATE_STARTED, \
NOTIFICATIONS_DEFAULTS, TASK_SETTINGS
NOTIFICATIONS_DEFAULTS, TASK_SETTINGS, DEFAULT_STOP_TIMEOUT
from conf.celeryconfig import CLUSTER_NAME
from deployer.celery import app
from deployer.tasks.exceptions import NodeNotUndeployed, MinNodesNotRunning, \
Expand All @@ -26,6 +26,7 @@


NOW = datetime.datetime(2014, 01, 01)
DEFAULT_STOP_TIMEOUT_SECONDS = 30


def test_create():
Expand Down Expand Up @@ -114,7 +115,7 @@ def test_deployment_defaults_for_type_git_quay(mock_time):
'timeout': '10s'
},
'stop': {
'timeout': '30s',
'timeout': DEFAULT_STOP_TIMEOUT,
'check-retries':
TASK_SETTINGS['DEFAULT_DEPLOYMENT_STOP_CHECK_RETRIES']
}
Expand All @@ -131,7 +132,7 @@ def test_deployment_defaults_for_type_git_quay(mock_time):
'image': 'quay.io/totem/testowner-testrepo:testcommit',
'sidekicks': ['yoda-register'],
'service': {
'container-stop-sec': 30
'container-stop-sec': DEFAULT_STOP_TIMEOUT_SECONDS
}
},
'enabled': True,
Expand Down Expand Up @@ -227,7 +228,7 @@ def test_deployment_defaults_with_proxy(mock_time):
'timeout': '10s'
},
'stop': {
'timeout': '30s',
'timeout': DEFAULT_STOP_TIMEOUT,
'check-retries':
TASK_SETTINGS['DEFAULT_DEPLOYMENT_STOP_CHECK_RETRIES']
}
Expand All @@ -246,7 +247,7 @@ def test_deployment_defaults_with_proxy(mock_time):
'image': 'quay.io/totem/testowner-testrepo:testcommit',
'sidekicks': ['yoda-register'],
'service': {
'container-stop-sec': 30
'container-stop-sec': DEFAULT_STOP_TIMEOUT_SECONDS
}
},
'enabled': True,
Expand Down Expand Up @@ -359,7 +360,7 @@ def test_deployment_defaults_for_type_git_quay_with_overrides(mock_time):
'timeout': '10s'
},
'stop': {
'timeout': '30s',
'timeout': DEFAULT_STOP_TIMEOUT,
'check-retries':
TASK_SETTINGS['DEFAULT_DEPLOYMENT_STOP_CHECK_RETRIES']
}
Expand All @@ -376,7 +377,7 @@ def test_deployment_defaults_for_type_git_quay_with_overrides(mock_time):
'image': 'quay.io/totem/testowner-testrepo:testcommit',
'sidekicks': ['yoda-register'],
'service': {
'container-stop-sec': 30
'container-stop-sec': DEFAULT_STOP_TIMEOUT_SECONDS
}
},
'enabled': True,
Expand Down Expand Up @@ -470,7 +471,7 @@ def test_deployment_defaults_for_custom_deployment(mock_time):
'timeout': '10s'
},
'stop': {
'timeout': '30s',
'timeout': DEFAULT_STOP_TIMEOUT,
'check-retries':
TASK_SETTINGS['DEFAULT_DEPLOYMENT_STOP_CHECK_RETRIES']
}
Expand All @@ -485,7 +486,7 @@ def test_deployment_defaults_for_custom_deployment(mock_time):
'DISCOVER_HEALTH': '{}'
},
'service': {
'container-stop-sec': 30
'container-stop-sec': DEFAULT_STOP_TIMEOUT_SECONDS
},
'sidekicks': []
},
Expand Down Expand Up @@ -524,7 +525,9 @@ def mock_callback(): # pragma: no cover

@patch('deployer.tasks.deployment.undeploy')
@patch('deployer.tasks.deployment.fetch_runtime_units')
def test_pre_create_undeploy_for_red_green(mock_filter_units, mock_undeploy):
@patch('deployer.tasks.deployment.stop')
def test_pre_create_undeploy_for_red_green(m_stop, mock_filter_units,
mock_undeploy):
"""
Should un-deploy all versions for mode: red-green
"""
Expand All @@ -544,11 +547,15 @@ def test_pre_create_undeploy_for_red_green(mock_filter_units, mock_undeploy):
# Then: All versions of application are un-deployed.
mock_undeploy.assert_called_with(ANY, deployment['deployment']['name'],
None, exclude_version=None)
m_stop.assert_called_with(ANY, deployment['deployment']['name'],
version=None, exclude_version=None)


@patch('deployer.tasks.deployment.undeploy')
@patch('deployer.tasks.deployment.fetch_runtime_units')
def test_pre_create_undeploy_for_blue_green(mock_filter_units, mock_undeploy):
@patch('deployer.tasks.deployment.stop')
def test_pre_create_undeploy_for_blue_green(m_stop, mock_filter_units,
mock_undeploy):
"""
Should undeploy all versions for mode: red-green
"""
Expand All @@ -569,11 +576,15 @@ def test_pre_create_undeploy_for_blue_green(mock_filter_units, mock_undeploy):
mock_undeploy.assert_called_with(ANY, deployment['deployment']['name'],
deployment['deployment']['version'],
exclude_version=None)
m_stop.assert_called_with(
ANY, deployment['deployment']['name'],
version=deployment['deployment']['version'], exclude_version=None)


@patch('deployer.tasks.deployment.undeploy')
@patch('deployer.tasks.deployment.fetch_runtime_units')
def test_pre_create_undeploy_for_ab(mock_filter_units, mock_undeploy):
@patch('deployer.tasks.deployment.stop')
def test_pre_create_undeploy_for_ab(m_stop, mock_filter_units, mock_undeploy):
"""
Should undeploy all versions for mode: red-green
"""
Expand All @@ -592,6 +603,7 @@ def test_pre_create_undeploy_for_ab(mock_filter_units, mock_undeploy):

# Then: All versions of application are un-deployed.
mock_undeploy.assert_not_called()
m_stop.assert_not_called()


@raises(NodeNotUndeployed)
Expand Down

0 comments on commit 756a322

Please sign in to comment.