From 257ef9fae82dda82d3ef477919c14aa3a8915971 Mon Sep 17 00:00:00 2001 From: Michal Arbet Date: Tue, 10 May 2022 09:39:28 +0200 Subject: [PATCH] Fix redis_sentinel container restarts Redis Sentinel modifies its config. Since we now check config in check-containers, the redis_sentintel container is restarted each time. This patch together with kolla patch fixes this issue. Closes-Bug: #1967664 Depends-On: https://review.opendev.org/c/openstack/kolla/+/840954 Change-Id: Ia76329cb851d266cd888f51b7f70a4cdc40e3ac3 --- ansible/roles/redis/defaults/main.yml | 6 ++++++ ansible/roles/redis/handlers/main.yml | 1 + ansible/roles/redis/tasks/check-containers.yml | 1 + ansible/roles/redis/templates/redis-sentinel.json.j2 | 8 ++++++-- ansible/roles/redis/templates/redis.json.j2 | 4 ++-- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/ansible/roles/redis/defaults/main.yml b/ansible/roles/redis/defaults/main.yml index 1a95a81aef..5f796911f1 100644 --- a/ansible/roles/redis/defaults/main.yml +++ b/ansible/roles/redis/defaults/main.yml @@ -11,6 +11,9 @@ redis_services: redis-sentinel: container_name: redis_sentinel group: redis + environment: + REDIS_CONF: "{{ redis_conf_path }}" + REDIS_GEN_CONF: "{{ redis_generated_conf_path }}" enabled: true image: "{{ redis_sentinel_image_full }}" volumes: "{{ redis_sentinel_default_volumes + redis_sentinel_extra_volumes }}" @@ -70,3 +73,6 @@ redis_sentinel_default_volumes: redis_extra_volumes: "{{ default_extra_volumes }}" redis_sentinel_extra_volumes: "{{ default_extra_volumes }}" + +redis_conf_path: "/etc/redis/redis.conf" +redis_generated_conf_path: "/etc/redis/redis-regenerated-by-config-rewrite.conf" diff --git a/ansible/roles/redis/handlers/main.yml b/ansible/roles/redis/handlers/main.yml index f0d2de78ad..b0a5de770a 100644 --- a/ansible/roles/redis/handlers/main.yml +++ b/ansible/roles/redis/handlers/main.yml @@ -25,6 +25,7 @@ common_options: "{{ docker_common_options }}" name: "{{ service.container_name }}" image: "{{ service.image }}" + environment: "{{ service.environment }}" volumes: "{{ service.volumes }}" dimensions: "{{ service.dimensions }}" healthcheck: "{{ service.healthcheck | default(omit) }}" diff --git a/ansible/roles/redis/tasks/check-containers.yml b/ansible/roles/redis/tasks/check-containers.yml index 24e168b88a..0d32104ee7 100644 --- a/ansible/roles/redis/tasks/check-containers.yml +++ b/ansible/roles/redis/tasks/check-containers.yml @@ -6,6 +6,7 @@ common_options: "{{ docker_common_options }}" name: "{{ item.value.container_name }}" image: "{{ item.value.image }}" + environment: "{{ item.environment | default(omit) }}" volumes: "{{ item.value.volumes }}" dimensions: "{{ item.value.dimensions }}" healthcheck: "{{ item.value.healthcheck | default(omit) }}" diff --git a/ansible/roles/redis/templates/redis-sentinel.json.j2 b/ansible/roles/redis/templates/redis-sentinel.json.j2 index b8df171bb0..d062cefc44 100644 --- a/ansible/roles/redis/templates/redis-sentinel.json.j2 +++ b/ansible/roles/redis/templates/redis-sentinel.json.j2 @@ -1,9 +1,9 @@ { - "command": "redis-sentinel /etc/redis/redis.conf", + "command": "redis-sentinel {{ redis_generated_conf_path }}", "config_files": [ { "source": "{{ container_config_directory }}/redis.conf", - "dest": "/etc/redis/redis.conf", + "dest": "{{ redis_conf_path }}", "owner": "redis", "perm": "0600" } @@ -13,6 +13,10 @@ "path": "/var/log/kolla/redis", "owner": "redis:redis", "recurse": true + }, + { + "path": "/etc/redis", + "owner": "redis:redis" } ] } diff --git a/ansible/roles/redis/templates/redis.json.j2 b/ansible/roles/redis/templates/redis.json.j2 index 063c2ad69f..02de435a38 100644 --- a/ansible/roles/redis/templates/redis.json.j2 +++ b/ansible/roles/redis/templates/redis.json.j2 @@ -1,9 +1,9 @@ { - "command": "redis-server /etc/redis/redis.conf", + "command": "redis-server {{ redis_conf_path }}", "config_files": [ { "source": "{{ container_config_directory }}/redis.conf", - "dest": "/etc/redis/redis.conf", + "dest": "{{ redis_conf_path }}", "owner": "redis", "perm": "0600" }