Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate case of starting an existing supervisord process group success reported as failure. #36972

Merged
merged 1 commit into from Oct 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 29 additions & 17 deletions salt/states/supervisord.py
Expand Up @@ -26,9 +26,11 @@ def _check_error(result, success_message):
ret = {}

if 'ERROR' in result:
if 'already started' in result:
ret['comment'] = success_message
elif 'not running' in result:
if any(substring in result for substring in [
'already started',
'not running',
'process group already active'
]):
ret['comment'] = success_message
else:
ret['comment'] = result
Expand Down Expand Up @@ -151,13 +153,36 @@ def running(name,

changes = []
just_updated = False
if to_add:

if update:
# If the state explicitly asks to update, we don't care if the process
# is being added or not, since it'll take care of this for us,
# so give this condition priority in order
#
# That is, unless `to_add` somehow manages to contain processes
# we don't want running, in which case adding them may be a mistake
comment = 'Updating supervisor'
result = __salt__['supervisord.update'](
user=user,
conf_file=conf_file,
bin_env=bin_env
)
ret.update(_check_error(result, comment))
log.debug(comment)

if '{0}: updated'.format(name) in result:
just_updated = True
elif to_add:
# Not sure if this condition is precise enough.
comment = 'Adding service: {0}'.format(name)
__salt__['supervisord.reread'](
user=user,
conf_file=conf_file,
bin_env=bin_env
)
# Causes supervisorctl to throw `ERROR: process group already active`
# if process group exists. At this moment, I'm not sure how to handle
# this outside of grepping out the expected string in `_check_error`.
result = __salt__['supervisord.add'](
name,
user=user,
Expand All @@ -169,19 +194,6 @@ def running(name,
changes.append(comment)
log.debug(comment)

elif update:
comment = 'Updating supervisor'
result = __salt__['supervisord.update'](
user=user,
conf_file=conf_file,
bin_env=bin_env
)
ret.update(_check_error(result, comment))
log.debug(comment)

if '{0}: updated'.format(name) in result:
just_updated = True

is_stopped = None

process_type = None
Expand Down