From 80fe68beb88c5ec4fb4cea5196a85ab937ea76e8 Mon Sep 17 00:00:00 2001 From: Lars Kellogg-Stedman Date: Wed, 12 Jul 2017 15:40:54 -0400 Subject: [PATCH] healthchecks: start to implement container healthchecks This is the first in a series of patches that will implement healthchecks for containerized services, conforming to the Docker HEALTHCHECK api and to the container-healthchecks blueprint. This commit includes an example healtcheck (for heat-api), and modifies the pep8 check to error out on duplicate jinja blocks in container-images/tripleo_kolla_template_overrides.j2, since we will be adding or modifying the _footer block for each service. Change-Id: Id9fc19dd386e395317093d1723b836ae2807fdf0 Implements: blueprint container-healthchecks Co-authored-by: Dan Prince Co-authored-by: Ian Main --- .../tripleo_kolla_template_overrides.j2 | 2 +- healthcheck/heat-api | 5 +++++ setup.cfg | 1 + tools/check_duplicate_jinja_blocks.sh | 21 +++++++++++++++++++ tox.ini | 2 ++ 5 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 healthcheck/heat-api create mode 100755 tools/check_duplicate_jinja_blocks.sh diff --git a/container-images/tripleo_kolla_template_overrides.j2 b/container-images/tripleo_kolla_template_overrides.j2 index 04f5e00f3..6a343c07b 100644 --- a/container-images/tripleo_kolla_template_overrides.j2 +++ b/container-images/tripleo_kolla_template_overrides.j2 @@ -8,7 +8,7 @@ # This installs the puppet dependency in the base container and includes helper scripts # Rsync is required for docker-puppet.py to move the generated config to /var/lib/config-data # Cron is required by multiple services -{% set base_centos_binary_packages_append = ['openstack-tripleo-common-container-base', 'rsync', 'cronie'] %} +{% set base_centos_binary_packages_append = ['openstack-tripleo-common-container-base', 'rsync', 'cronie', 'crudini'] %} {% set nova_scheduler_packages_append = ['openstack-tripleo-common'] %} # Required for mistral-db-populate to load tripleo custom actions on diff --git a/healthcheck/heat-api b/healthcheck/heat-api new file mode 100755 index 000000000..db85faf70 --- /dev/null +++ b/healthcheck/heat-api @@ -0,0 +1,5 @@ +#!/bin/sh + +bind_host=$(crudini --get /etc/heat/heat.conf heat_api bind_host 2> /dev/null || echo 127.0.0.1) +bind_port=$(crudini --get /etc/heat/heat.conf heat_api bind_port 2> /dev/null || echo 8004) +curl --fail http://${bind_host}:${bind_port}/ || exit 1 diff --git a/setup.cfg b/setup.cfg index 33be86f21..165c27cbf 100644 --- a/setup.cfg +++ b/setup.cfg @@ -39,6 +39,7 @@ data_files = share/tripleo-common/container-images = container-images/* share/tripleo-common/image-yaml = image-yaml/* share/tripleo-common/workbooks = workbooks/* + share/tripleo-common/healthcheck = healthcheck/* [build_sphinx] source-dir = doc/source diff --git a/tools/check_duplicate_jinja_blocks.sh b/tools/check_duplicate_jinja_blocks.sh new file mode 100755 index 000000000..52806c18c --- /dev/null +++ b/tools/check_duplicate_jinja_blocks.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +myname=${0##*/} +path=container-images/tripleo_kolla_template_overrides.j2 + +grep '{% block' $path | +sort | +uniq -c | +awk -v myname=$myname ' + $1 == 2 { + printf "%s: found duplicate block for %s\n", myname, $4 + retval=1 + } + + END {exit retval} +' + +if [ $? -ne 0 ]; then + echo "$myname: duplicate jinja block declarations found in $path" >&2 + exit 1 +fi diff --git a/tox.ini b/tox.ini index b923f838c..f3fa795ce 100644 --- a/tox.ini +++ b/tox.ini @@ -12,9 +12,11 @@ setenv = deps = -r{toxinidir}/requirements.txt -r{toxinidir}/test-requirements.txt commands = python setup.py test --slowest --testr-args='{posargs}' +whitelist_externals = bash [testenv:pep8] commands = flake8 + bash -c tools/check_duplicate_jinja_blocks.sh [testenv:venv] commands = {posargs}