diff --git a/docker/base/Dockerfile.j2 b/docker/base/Dockerfile.j2 index 88835774e6..ff5d853b3d 100644 --- a/docker/base/Dockerfile.j2 +++ b/docker/base/Dockerfile.j2 @@ -401,8 +401,9 @@ COPY start.sh /usr/local/bin/kolla_start COPY sudoers /etc/sudoers COPY curlrc /root/.curlrc -{% block dumb_init_installation %} +{% if use_dumb_init %} +{% block dumb_init_installation %} {% if base_arch == 'x86_64' %} RUN curl -sSL https://github.com/Yelp/dumb-init/releases/download/v1.1.3/dumb-init_1.1.3_amd64 -o /usr/local/bin/dumb-init \ @@ -421,9 +422,10 @@ RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \ {% endif %} ENTRYPOINT ["dumb-init", "--single-child", "--"] - {% endblock %} +{% endif %} + RUN touch /usr/local/bin/kolla_extend_start \ && chmod 755 /usr/local/bin/kolla_start /usr/local/bin/kolla_extend_start /usr/local/bin/kolla_set_configs \ && chmod 440 /etc/sudoers \ diff --git a/docker/mariadb/Dockerfile.j2 b/docker/mariadb/Dockerfile.j2 index 6af2bfb6c7..02c212e7d9 100644 --- a/docker/mariadb/Dockerfile.j2 +++ b/docker/mariadb/Dockerfile.j2 @@ -57,6 +57,20 @@ RUN chmod 755 /usr/local/bin/kolla_extend_start \ {% if base_distro in ['debian', 'ubuntu'] %} RUN mkdir -p /var/run/mysqld && chown mysql /var/run/mysqld && chmod 755 /var/run/mysqld {% endif %} + +{% if use_dumb_init %} +{% block mariadb_entrypoint %} +# NOTE(mgoddard): Override the dumb-init arguments to avoid passing +# --single-child. This does not play well with mysqld_safe, which ignores +# SIGTERM, meaning Docker needs to forcibly kill the container to stop it. +# Without --single-child, the TERM signal is sent to all subprocesses, +# including mysqld. + +ENTRYPOINT ["dumb-init", "--"] +CMD ["kolla_start"] +{% endblock %} +{% endif %} + {% block mariadb_footer %}{% endblock %} {% block footer %}{% endblock %} diff --git a/kolla/common/config.py b/kolla/common/config.py index d45b97c2bb..d136d408d3 100755 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -188,6 +188,8 @@ _CLI_OPTS = [ cfg.StrOpt('base-arch', default=hostarch, choices=BASE_ARCH, help='The base architecture. Default is same as host'), + cfg.BoolOpt('use-dumb-init', default=True, + help='Use dumb-init as init system in containers'), cfg.BoolOpt('debug', short='d', default=False, help='Turn on debugging log level'), cfg.BoolOpt('skip-parents', default=False, diff --git a/kolla/image/build.py b/kolla/image/build.py index f38efde0b2..092ff08a64 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -665,6 +665,7 @@ class KollaWorker(object): else: self.namespace = conf.namespace self.base = conf.base + self.use_dumb_init = conf.use_dumb_init self.base_tag = conf.base_tag self.install_type = conf.install_type self.tag = conf.tag @@ -868,6 +869,7 @@ class KollaWorker(object): 'base_image': self.conf.base_image, 'base_distro_tag': self.base_tag, 'base_arch': self.base_arch, + 'use_dumb_init': self.use_dumb_init, 'supported_distro_release': supported_distro_release, 'install_metatype': self.install_metatype, 'image_prefix': self.image_prefix, diff --git a/releasenotes/notes/add-use-dumb-init-config-option-26b47f6d97d7585c.yaml b/releasenotes/notes/add-use-dumb-init-config-option-26b47f6d97d7585c.yaml new file mode 100644 index 0000000000..7042aa7dd6 --- /dev/null +++ b/releasenotes/notes/add-use-dumb-init-config-option-26b47f6d97d7585c.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + Adds configration option ``use_dumb_init``, with default value of ``True``. + This can be use to avoid the of ``dumb-init`` as the container entrypoint, + using ``kolla_start`` directly instead. This option can also be disabled + via the ``kolla-build --nouse-dumb-init`` CLI argument.