Merge "Remove vbmc
feature of starting up vbmcd
"
This commit is contained in:
commit
9742c04208
@ -0,0 +1,6 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
Removes the backward compatibility feature of ``vbmc`` to automatically
|
||||
start up ``vbmcd`` daemon process if it is not running. From now on,
|
||||
``vbmcd`` should be started by systemd or some other mechanism.
|
@ -13,7 +13,6 @@
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
|
||||
from cliff.app import App
|
||||
from cliff.command import Command
|
||||
@ -23,11 +22,9 @@ from cliff.lister import Lister
|
||||
import zmq
|
||||
|
||||
import virtualbmc
|
||||
from virtualbmc.cmd import vbmcd
|
||||
from virtualbmc import config as vbmc_config
|
||||
from virtualbmc.exception import VirtualBMCError
|
||||
from virtualbmc import log
|
||||
from virtualbmc import utils
|
||||
|
||||
CONF = vbmc_config.get_config()
|
||||
|
||||
@ -78,49 +75,22 @@ class ZmqClient(object):
|
||||
poller = zmq.Poller()
|
||||
poller.register(socket, zmq.POLLIN)
|
||||
|
||||
while True:
|
||||
try:
|
||||
if data_out:
|
||||
socket.send(data_out.encode('utf-8'))
|
||||
try:
|
||||
socket.send(data_out.encode('utf-8'))
|
||||
|
||||
socks = dict(poller.poll(timeout=self.SERVER_TIMEOUT))
|
||||
if socket in socks and socks[socket] == zmq.POLLIN:
|
||||
data_in = socket.recv()
|
||||
break
|
||||
socks = dict(poller.poll(timeout=self.SERVER_TIMEOUT))
|
||||
if socket in socks and socks[socket] == zmq.POLLIN:
|
||||
data_in = socket.recv()
|
||||
|
||||
else:
|
||||
raise zmq.ZMQError(
|
||||
zmq.RCVTIMEO, msg='Server response timed out')
|
||||
|
||||
except zmq.ZMQError as ex:
|
||||
LOG.debug('Server at %(port)s connection error: '
|
||||
'%(error)s', {'port': server_port, 'error': ex})
|
||||
|
||||
if no_daemon:
|
||||
msg = ('Server at %(port)s may be dead, will not '
|
||||
'try to revive it' % {'port': server_port})
|
||||
LOG.error(msg)
|
||||
raise VirtualBMCError(msg)
|
||||
|
||||
no_daemon = True
|
||||
|
||||
LOG.debug("Attempting to start `vbmcd` behind the "
|
||||
"scenes. Consider configuring your system to "
|
||||
"manage `vbmcd` via systemd. Automatic "
|
||||
"`vbmcd` start up will be removed in the "
|
||||
"future releases!")
|
||||
|
||||
# attempt to start and daemonize the server
|
||||
with utils.detach_process() as pid:
|
||||
if pid == 0:
|
||||
# NOTE(etingof): this child will never return
|
||||
vbmcd.main(['--foreground'])
|
||||
|
||||
# TODO(etingof): perform some more retries
|
||||
time.sleep(CONF['default']['server_spawn_wait'] / 1000.)
|
||||
|
||||
# MQ will deliver the original message to the daemon
|
||||
# we've started
|
||||
data_out = {}
|
||||
except zmq.ZMQError as ex:
|
||||
msg = ('Server at %(port)s connection error: '
|
||||
'%(error)s' % {'port': server_port, 'error': ex})
|
||||
LOG.error(msg)
|
||||
raise VirtualBMCError(msg)
|
||||
|
||||
finally:
|
||||
if socket:
|
||||
|
@ -36,8 +36,8 @@ class VBMCTestCase(base.TestCase):
|
||||
@mock.patch.object(zmq, 'Poller')
|
||||
def test_server_timeout(self, mock_zmq_poller, mock_zmq_context):
|
||||
expected_rc = 1
|
||||
expected_output = ('Server at 50891 may be dead, '
|
||||
'will not try to revive it\n')
|
||||
expected_output = (
|
||||
'Server at 50891 connection error: Server response timed out\n')
|
||||
|
||||
mock_zmq_poller = mock_zmq_poller.return_value
|
||||
mock_zmq_poller.poll.return_value = {}
|
||||
|
Loading…
Reference in New Issue
Block a user