mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #49615 from terminalmage/ping-interval
ping_interval: use service.restart instead of signaling
This commit is contained in:
commit
f745e438b3
@ -410,6 +410,13 @@ def master_event(type, master=None):
|
||||
return event_map.get(type, None)
|
||||
|
||||
|
||||
def service_name():
|
||||
'''
|
||||
Return the proper service name based on platform
|
||||
'''
|
||||
return 'salt_minion' if 'bsd' in sys.platform else 'salt-minion'
|
||||
|
||||
|
||||
class MinionBase(object):
|
||||
def __init__(self, opts):
|
||||
self.opts = opts
|
||||
@ -2619,8 +2626,17 @@ class Minion(MinionBase):
|
||||
log.error('** Master Ping failed. Attempting to restart minion**')
|
||||
delay = self.opts.get('random_reauth_delay', 5)
|
||||
log.info('delaying random_reauth_delay %ss', delay)
|
||||
# regular sys.exit raises an exception -- which isn't sufficient in a thread
|
||||
os._exit(salt.defaults.exitcodes.SALT_KEEPALIVE)
|
||||
try:
|
||||
self.functions['service.restart'](service_name())
|
||||
except KeyError:
|
||||
# Probably no init system (running in docker?)
|
||||
log.warning(
|
||||
'ping_interval reached without response '
|
||||
'from the master, but service.restart '
|
||||
'could not be run to restart the minion '
|
||||
'daemon. ping_interval requires that the '
|
||||
'minion is running under an init system.'
|
||||
)
|
||||
|
||||
self._fire_master('ping', 'minion_ping', sync=False, timeout_handler=ping_timeout_handler)
|
||||
except Exception:
|
||||
|
Loading…
Reference in New Issue
Block a user