Merge pull request #49511 from rallytime/merge-2018.3

[2018.3] Merge forward from 2018.3.3 to 2018.3
This commit is contained in:
Nicole Thomas 2018-09-05 15:52:24 -04:00 committed by GitHub
commit f73f2e5bb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 21 deletions

View file

@ -4,5 +4,6 @@ yappi>=0.8.2
--allow-unverified python-novaclient>2.17.0
--allow-unverified python-neutronclient>2.3.6
python-gnupg
cherrypy>=3.2.2
cherrypy>=3.2.2,<18.0.0; python_version < '3.5'
cherrypy>=3.2.2; python_version >= '3.5'
libnacl

View file

@ -21,7 +21,8 @@ kubernetes<4.0
psutil
pyvmomi
setproctitle
cherrypy; sys.platform != 'win32' and sys.platform != 'darwin'
cherrypy>=3.2.2,<18.0.0; python_version < '3.5' and sys.platform != 'win32' and sys.platform != 'darwin'
cherrypy>=3.2.2; python_version >= '3.5' and sys.platform != 'win32' and sys.platform != 'darwin'
ldap; sys.platform != 'win32' and sys.platform != 'darwin'
pyinotify; sys.platform != 'win32' and sys.platform != 'darwin'
PyMySQL; sys.platform != 'win32' and sys.platform != 'darwin'

View file

@ -112,6 +112,8 @@ def minion_process():
def handle_hup(manager, sig, frame):
manager.minion.reload()
lock = threading.RLock()
def suicide_when_without_parent(parent_pid):
'''
Have the minion suicide if the parent process is gone
@ -119,7 +121,8 @@ def minion_process():
NOTE: small race issue where the parent PID could be replace
with another process with same PID!
'''
while True:
while lock.acquire(blocking=False):
lock.release()
time.sleep(5)
try:
# check pid alive (Unix only trick!)
@ -131,18 +134,18 @@ def minion_process():
log.error('Minion process encountered exception: %s', exc)
os._exit(salt.defaults.exitcodes.EX_GENERIC)
if not salt.utils.platform.is_windows():
thread = threading.Thread(target=suicide_when_without_parent, args=(os.getppid(),))
thread.start()
minion = salt.cli.daemons.Minion()
signal.signal(signal.SIGHUP,
functools.partial(handle_hup,
minion))
try:
if not salt.utils.platform.is_windows():
thread = threading.Thread(target=suicide_when_without_parent, args=(os.getppid(),))
thread.start()
minion = salt.cli.daemons.Minion()
signal.signal(signal.SIGHUP,
functools.partial(handle_hup,
minion))
minion.start()
except (SaltClientError, SaltReqTimeoutError, SaltSystemExit) as exc:
lock.acquire(blocking=True)
log.warning('Fatal functionality error caught by minion handler:\n', exc_info=True)
log.warning('** Restarting minion **')
delay = 60
@ -152,6 +155,8 @@ def minion_process():
log.info('waiting random_reauth_delay %ss', delay)
time.sleep(delay)
sys.exit(salt.defaults.exitcodes.SALT_KEEPALIVE)
finally:
lock.acquire(blocking=True)
def salt_minion():
@ -240,6 +245,8 @@ def proxy_minion_process(queue):
import salt.utils.platform
# salt_minion spawns this function in a new process
lock = threading.RLock()
def suicide_when_without_parent(parent_pid):
'''
Have the minion suicide if the parent process is gone
@ -247,7 +254,8 @@ def proxy_minion_process(queue):
NOTE: there is a small race issue where the parent PID could be replace
with another process with the same PID!
'''
while True:
while lock.acquire(blocking=False):
lock.release()
time.sleep(5)
try:
# check pid alive (Unix only trick!)
@ -257,14 +265,14 @@ def proxy_minion_process(queue):
# isn't sufficient in a thread
os._exit(999)
if not salt.utils.platform.is_windows():
thread = threading.Thread(target=suicide_when_without_parent, args=(os.getppid(),))
thread.start()
restart = False
proxyminion = None
status = salt.defaults.exitcodes.EX_OK
try:
if not salt.utils.platform.is_windows():
thread = threading.Thread(target=suicide_when_without_parent, args=(os.getppid(),))
thread.start()
restart = False
proxyminion = None
status = salt.defaults.exitcodes.EX_OK
proxyminion = salt.cli.daemons.ProxyMinion()
proxyminion.start()
except (Exception, SaltClientError, SaltReqTimeoutError, SaltSystemExit) as exc:
@ -275,6 +283,8 @@ def proxy_minion_process(queue):
except SystemExit as exc:
restart = False
status = exc.code
finally:
lock.acquire(blocking=True)
if restart is True:
log.warning('** Restarting proxy minion **')

View file

@ -22,7 +22,10 @@
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
from collections import Callable
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
# Import 3rd-party libs
from salt.ext import six

View file

@ -6,6 +6,7 @@ import random
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.helpers import flaky
from tests.support.unit import skipIf
# Import Salt libs
@ -18,6 +19,7 @@ class StatusModuleTest(ModuleCase):
Test the status module
'''
@skipIf(salt.utils.platform.is_windows(), 'minion is windows')
@flaky
def test_status_pid(self):
'''
status.pid