Merge "Check for the service queue with ephemeral heat"
This commit is contained in:
commit
ed676d6d94
|
@ -2,8 +2,8 @@ apiVersion: v1
|
||||||
kind: Pod
|
kind: Pod
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: ephemeral-heat
|
app: {{ heat_pod_name }}
|
||||||
name: ephemeral-heat
|
name: {{ heat_pod_name }}
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- command:
|
- command:
|
||||||
|
|
|
@ -33,6 +33,7 @@ OVERCLOUD_NETWORKS_FILE = "network_data.yaml"
|
||||||
STANDALONE_NETWORKS_FILE = "/dev/null"
|
STANDALONE_NETWORKS_FILE = "/dev/null"
|
||||||
UNDERCLOUD_NETWORKS_FILE = "network_data_undercloud.yaml"
|
UNDERCLOUD_NETWORKS_FILE = "network_data_undercloud.yaml"
|
||||||
ANSIBLE_HOSTS_FILENAME = "hosts.yaml"
|
ANSIBLE_HOSTS_FILENAME = "hosts.yaml"
|
||||||
|
EPHEMERAL_HEAT_POD_NAME = "ephemeral-heat"
|
||||||
ANSIBLE_CWL = "tripleo_dense,tripleo_profile_tasks,tripleo_states"
|
ANSIBLE_CWL = "tripleo_dense,tripleo_profile_tasks,tripleo_states"
|
||||||
CONTAINER_IMAGE_PREPARE_LOG_FILE = "container_image_prepare.log"
|
CONTAINER_IMAGE_PREPARE_LOG_FILE = "container_image_prepare.log"
|
||||||
DEFAULT_CONTAINER_REGISTRY = "quay.io"
|
DEFAULT_CONTAINER_REGISTRY = "quay.io"
|
||||||
|
|
|
@ -37,7 +37,8 @@ from tenacity.wait import wait_fixed
|
||||||
from tripleoclient.constants import (DEFAULT_HEAT_CONTAINER,
|
from tripleoclient.constants import (DEFAULT_HEAT_CONTAINER,
|
||||||
DEFAULT_HEAT_API_CONTAINER,
|
DEFAULT_HEAT_API_CONTAINER,
|
||||||
DEFAULT_HEAT_ENGINE_CONTAINER,
|
DEFAULT_HEAT_ENGINE_CONTAINER,
|
||||||
DEFAULT_TEMPLATES_DIR)
|
DEFAULT_TEMPLATES_DIR,
|
||||||
|
EPHEMERAL_HEAT_POD_NAME)
|
||||||
from tripleoclient.exceptions import HeatPodMessageQueueException
|
from tripleoclient.exceptions import HeatPodMessageQueueException
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
@ -478,7 +479,7 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
def get_pod_state(self):
|
def get_pod_state(self):
|
||||||
inspect = subprocess.run([
|
inspect = subprocess.run([
|
||||||
'sudo', 'podman', 'pod', 'inspect', '--format',
|
'sudo', 'podman', 'pod', 'inspect', '--format',
|
||||||
'"{{.State}}"', 'ephemeral-heat'],
|
'"{{.State}}"', EPHEMERAL_HEAT_POD_NAME],
|
||||||
check=False,
|
check=False,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
|
@ -486,7 +487,8 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
|
|
||||||
def launch_heat(self):
|
def launch_heat(self):
|
||||||
if "Running" in self.get_pod_state():
|
if "Running" in self.get_pod_state():
|
||||||
log.info("ephemeral-heat pod already running, skipping launch")
|
log.info("%s pod already running, skipping launch",
|
||||||
|
EPHEMERAL_HEAT_POD_NAME)
|
||||||
return
|
return
|
||||||
self._write_heat_pod()
|
self._write_heat_pod()
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
|
@ -570,7 +572,7 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
def pod_exists(self):
|
def pod_exists(self):
|
||||||
try:
|
try:
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
['sudo', 'podman', 'pod', 'inspect', 'ephemeral-heat'],
|
['sudo', 'podman', 'pod', 'inspect', EPHEMERAL_HEAT_POD_NAME],
|
||||||
stdout=subprocess.DEVNULL,
|
stdout=subprocess.DEVNULL,
|
||||||
stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL)
|
||||||
return True
|
return True
|
||||||
|
@ -593,9 +595,10 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
if self.pod_exists():
|
if self.pod_exists():
|
||||||
log.info("Removing pod: ephemeral-heat")
|
log.info("Removing pod: %s", EPHEMERAL_HEAT_POD_NAME)
|
||||||
subprocess.call([
|
subprocess.call([
|
||||||
'sudo', 'podman', 'pod', 'rm', '-f', 'ephemeral-heat'
|
'sudo', 'podman', 'pod', 'rm', '-f',
|
||||||
|
EPHEMERAL_HEAT_POD_NAME
|
||||||
])
|
])
|
||||||
config = self._read_heat_config()
|
config = self._read_heat_config()
|
||||||
log_file_path = os.path.join(self.log_dir,
|
log_file_path = os.path.join(self.log_dir,
|
||||||
|
@ -605,11 +608,12 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
|
|
||||||
def stop_heat(self):
|
def stop_heat(self):
|
||||||
if self.pod_exists() and self.get_pod_state() != 'Exited':
|
if self.pod_exists() and self.get_pod_state() != 'Exited':
|
||||||
log.info("Stopping pod: ephemeral-heat")
|
log.info("Stopping pod: %s", EPHEMERAL_HEAT_POD_NAME)
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
'sudo', 'podman', 'pod', 'stop', 'ephemeral-heat'
|
'sudo', 'podman', 'pod', 'stop',
|
||||||
|
EPHEMERAL_HEAT_POD_NAME
|
||||||
])
|
])
|
||||||
log.info("Stopped pod: ephemeral-heat")
|
log.info("Stopped pod: %s", EPHEMERAL_HEAT_POD_NAME)
|
||||||
|
|
||||||
def check_message_bus(self):
|
def check_message_bus(self):
|
||||||
log.info("Checking that message bus (rabbitmq) is up")
|
log.info("Checking that message bus (rabbitmq) is up")
|
||||||
|
@ -650,13 +654,14 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
|
|
||||||
def kill_heat(self, pid):
|
def kill_heat(self, pid):
|
||||||
if self.pod_exists():
|
if self.pod_exists():
|
||||||
log.info("Killing pod: ephemeral-heat")
|
log.info("Killing pod: %s", EPHEMERAL_HEAT_POD_NAME)
|
||||||
subprocess.call([
|
subprocess.call([
|
||||||
'sudo', 'podman', 'pod', 'kill', 'ephemeral-heat'
|
'sudo', 'podman', 'pod', 'kill',
|
||||||
|
EPHEMERAL_HEAT_POD_NAME
|
||||||
])
|
])
|
||||||
log.info("Killed pod: ephemeral-heat")
|
log.info("Killed pod: %s", EPHEMERAL_HEAT_POD_NAME)
|
||||||
else:
|
else:
|
||||||
log.info("Pod does not exist: ephemeral-heat")
|
log.info("Pod does not exist: %s", EPHEMERAL_HEAT_POD_NAME)
|
||||||
|
|
||||||
def _decode(self, encoded):
|
def _decode(self, encoded):
|
||||||
if not encoded:
|
if not encoded:
|
||||||
|
@ -702,11 +707,11 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
stop=(stop_after_delay(10) | stop_after_attempt(10)),
|
stop=(stop_after_delay(10) | stop_after_attempt(10)),
|
||||||
wait=wait_fixed(0.5))
|
wait=wait_fixed(0.5))
|
||||||
def wait_for_message_queue(self):
|
def wait_for_message_queue(self):
|
||||||
|
queue_name = 'engine.' + EPHEMERAL_HEAT_POD_NAME
|
||||||
output = subprocess.check_output([
|
output = subprocess.check_output([
|
||||||
'sudo', 'podman', 'exec', 'rabbitmq',
|
'sudo', 'podman', 'exec', 'rabbitmq',
|
||||||
'rabbitmqctl', 'list_queues'
|
'rabbitmqctl', 'list_queues'])
|
||||||
])
|
if str(output).count(queue_name) < 1:
|
||||||
if 'heat' not in str(output):
|
|
||||||
msg = "Message queue for ephemeral heat not created in time."
|
msg = "Message queue for ephemeral heat not created in time."
|
||||||
raise HeatPodMessageQueueException(msg)
|
raise HeatPodMessageQueueException(msg)
|
||||||
|
|
||||||
|
@ -720,7 +725,7 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
|
|
||||||
def _write_heat_config(self):
|
def _write_heat_config(self):
|
||||||
heat_config_tmpl_path = os.path.join(DEFAULT_TEMPLATES_DIR,
|
heat_config_tmpl_path = os.path.join(DEFAULT_TEMPLATES_DIR,
|
||||||
"ephemeral-heat",
|
EPHEMERAL_HEAT_POD_NAME,
|
||||||
"heat.conf.j2")
|
"heat.conf.j2")
|
||||||
with open(heat_config_tmpl_path) as tmpl:
|
with open(heat_config_tmpl_path) as tmpl:
|
||||||
heat_config_tmpl = jinja2.Template(tmpl.read())
|
heat_config_tmpl = jinja2.Template(tmpl.read())
|
||||||
|
@ -739,7 +744,7 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
|
|
||||||
def _write_heat_pod(self):
|
def _write_heat_pod(self):
|
||||||
heat_pod_tmpl_path = os.path.join(DEFAULT_TEMPLATES_DIR,
|
heat_pod_tmpl_path = os.path.join(DEFAULT_TEMPLATES_DIR,
|
||||||
"ephemeral-heat",
|
EPHEMERAL_HEAT_POD_NAME,
|
||||||
"heat-pod.yaml.j2")
|
"heat-pod.yaml.j2")
|
||||||
with open(heat_pod_tmpl_path) as tmpl:
|
with open(heat_pod_tmpl_path) as tmpl:
|
||||||
heat_pod_tmpl = jinja2.Template(tmpl.read())
|
heat_pod_tmpl = jinja2.Template(tmpl.read())
|
||||||
|
@ -752,6 +757,7 @@ class HeatPodLauncher(HeatContainerLauncher):
|
||||||
"api_port": self.api_port,
|
"api_port": self.api_port,
|
||||||
"api_image": self.api_container_image,
|
"api_image": self.api_container_image,
|
||||||
"engine_image": self.engine_container_image,
|
"engine_image": self.engine_container_image,
|
||||||
|
"heat_pod_name": EPHEMERAL_HEAT_POD_NAME
|
||||||
}
|
}
|
||||||
heat_pod = heat_pod_tmpl.render(**pod_vars)
|
heat_pod = heat_pod_tmpl.render(**pod_vars)
|
||||||
|
|
||||||
|
|
|
@ -416,11 +416,11 @@ class TestHeatPodLauncher(base.TestCase):
|
||||||
def test_wait_for_message_queue(self):
|
def test_wait_for_message_queue(self):
|
||||||
launcher = self.get_launcher()
|
launcher = self.get_launcher()
|
||||||
wait_mq = launcher.wait_for_message_queue.__wrapped__
|
wait_mq = launcher.wait_for_message_queue.__wrapped__
|
||||||
self.check_output.return_value = 'heat'
|
self.check_output.return_value = 'engine.ephemeral-heat'
|
||||||
wait_mq(launcher)
|
wait_mq(launcher)
|
||||||
|
|
||||||
self.check_output.reset_mock()
|
self.check_output.reset_mock()
|
||||||
self.check_output.return_value = 'test'
|
self.check_output.return_value = 'heat-listener'
|
||||||
self.assertRaises(HeatPodMessageQueueException, wait_mq, launcher)
|
self.assertRaises(HeatPodMessageQueueException, wait_mq, launcher)
|
||||||
|
|
||||||
def test_get_log_file_path(self):
|
def test_get_log_file_path(self):
|
||||||
|
|
Loading…
Reference in New Issue