From e5fe2a33b991a5c8dc4a77b08bf7228d692e557b Mon Sep 17 00:00:00 2001 From: Michal Arbet Date: Thu, 21 Jul 2022 16:11:45 +0200 Subject: [PATCH] Run proxysql with proxysql user This patch is switching root user to proxysql user and provides some necessary changes to work. Change-Id: Id603cc1e9c084eac8afc4c6d2ddde9a1f4fe6728 --- docker/proxysql/Dockerfile.j2 | 12 +++++++++--- docker/proxysql/kolla_proxysql_config_sync | 4 ++-- docker/proxysql/kolla_proxysql_start | 9 --------- 3 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 docker/proxysql/kolla_proxysql_start diff --git a/docker/proxysql/Dockerfile.j2 b/docker/proxysql/Dockerfile.j2 index aadfae7b95..8e87a3c312 100644 --- a/docker/proxysql/Dockerfile.j2 +++ b/docker/proxysql/Dockerfile.j2 @@ -26,10 +26,16 @@ LABEL maintainer="{{ maintainer }}" name="{{ image_name }}" build-date="{{ build {{ macros.configure_user(name='proxysql') }} {{ macros.install_packages(proxysql_packages | customizable("packages")) }} -COPY kolla_proxysql_start kolla_proxysql_config_sync kolla_extend_start /usr/local/bin/ -RUN chmod 755 /usr/local/bin/kolla_proxysql_start \ - && chmod 755 /usr/local/bin/kolla_proxysql_config_sync \ +COPY kolla_proxysql_config_sync kolla_extend_start /usr/local/bin/ +RUN chmod 755 /usr/local/bin/kolla_proxysql_config_sync \ && chmod 644 /usr/local/bin/kolla_extend_start +RUN install -g proxysql -o proxysql -m 770 -d /var/lib/kolla/proxysql \ + && touch /etc/proxysql.cnf \ + && chown proxysql:proxysql /etc/proxysql.cnf \ + && chmod 600 /etc/proxysql.cnf + {% block proxysql_footer %}{% endblock %} {% block footer %}{% endblock %} + +USER proxysql diff --git a/docker/proxysql/kolla_proxysql_config_sync b/docker/proxysql/kolla_proxysql_config_sync index 956f691886..d6d531f30e 100644 --- a/docker/proxysql/kolla_proxysql_config_sync +++ b/docker/proxysql/kolla_proxysql_config_sync @@ -136,8 +136,8 @@ class ProxySQLConfig: def write_config(self): LOG.info("Writing config to {}".format(self.conf_file)) - if os.path.exists(self.conf_file): - os.remove(self.conf_file) + with open(self.conf_file, 'wb') as f: + pass for k, v in self.config.items(): if isinstance(v, dict): self._write_dict(k, v) diff --git a/docker/proxysql/kolla_proxysql_start b/docker/proxysql/kolla_proxysql_start deleted file mode 100644 index f24ee732a0..0000000000 --- a/docker/proxysql/kolla_proxysql_start +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -PROXYSQL_LOG_FILE="/var/log/kolla/proxysql/proxysql.log" - -proxysql \ - --exit-on-error \ - --idle-threads \ - --no-version-check \ - -f -D /var/lib/proxysql -c /etc/proxysql.cnf >> ${PROXYSQL_LOG_FILE} 2>&1