From f8c4407d2b3f19d2e5038bfc97d9c9c1e8d53327 Mon Sep 17 00:00:00 2001 From: Zeyad Kenawi Date: Sun, 13 Feb 2022 10:37:01 +0200 Subject: [PATCH 1/2] fix: add redisFailover name in shutdown script generator --- operator/redisfailover/service/generator.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/operator/redisfailover/service/generator.go b/operator/redisfailover/service/generator.go index 68e9d9a54..cd763f359 100644 --- a/operator/redisfailover/service/generator.go +++ b/operator/redisfailover/service/generator.go @@ -2,6 +2,7 @@ package service import ( "fmt" + "strings" "bytes" @@ -161,13 +162,14 @@ func generateRedisConfigMap(rf *redisfailoverv1.RedisFailover, labels map[string func generateRedisShutdownConfigMap(rf *redisfailoverv1.RedisFailover, labels map[string]string, ownerRefs []metav1.OwnerReference) *corev1.ConfigMap { name := GetRedisShutdownConfigMapName(rf) namespace := rf.Namespace + rfName := strings.ToUpper(rf.Name) labels = util.MergeLabels(labels, generateSelectorLabels(redisRoleName, rf.Name)) - shutdownContent := `master=$(redis-cli -h ${RFS_REDIS_SERVICE_HOST} -p ${RFS_REDIS_SERVICE_PORT_SENTINEL} --csv SENTINEL get-master-addr-by-name mymaster | tr ',' ' ' | tr -d '\"' |cut -d' ' -f1) + shutdownContent := fmt.Sprintf(`master=$(redis-cli -h ${RFS_%[1]v_SERVICE_HOST} -p ${RFS_%[1]v_SERVICE_PORT_SENTINEL} --csv SENTINEL get-master-addr-by-name mymaster | tr ',' ' ' | tr -d '\"' |cut -d' ' -f1) redis-cli SAVE if [ "$master" = "$(hostname -i)" ]; then - redis-cli -h ${RFS_REDIS_SERVICE_HOST} -p ${RFS_REDIS_SERVICE_PORT_SENTINEL} SENTINEL failover mymaster -fi` + redis-cli -h ${RFS_%[1]v_SERVICE_HOST} -p ${RFS_%[1]v_SERVICE_PORT_SENTINEL} SENTINEL failover mymaster +fi`, rfName) return &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ From 994cb73531e1b26ab93be63f28029397063b1cb2 Mon Sep 17 00:00:00 2001 From: Zeyad Kenawi Date: Sun, 13 Feb 2022 10:38:41 +0200 Subject: [PATCH 2/2] fix: example custom shutdown with the actuall redis failover name --- example/redisfailover/custom-shutdown.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/example/redisfailover/custom-shutdown.yaml b/example/redisfailover/custom-shutdown.yaml index 6b320102c..45bddcdcd 100644 --- a/example/redisfailover/custom-shutdown.yaml +++ b/example/redisfailover/custom-shutdown.yaml @@ -17,8 +17,8 @@ metadata: data: shutdown.sh: | echo "shutdown in progress..." - master=$(redis-cli -h ${RFS_REDIS_SERVICE_HOST} -p ${RFS_REDIS_SERVICE_PORT_SENTINEL} --csv SENTINEL get-master-addr-by-name mymaster | tr ',' ' ' | tr -d '\"' |cut -d' ' -f1) + master=$(redis-cli -h ${RFS_REDISFAILOVER_SERVICE_HOST} -p ${RFS_REDISFAILOVER_SERVICE_PORT_SENTINEL} --csv SENTINEL get-master-addr-by-name mymaster | tr ',' ' ' | tr -d '\"' |cut -d' ' -f1) redis-cli SAVE if [[ $master == $(hostname -i) ]]; then - redis-cli -h ${RFS_REDIS_SERVICE_HOST} -p ${RFS_REDIS_SERVICE_PORT_SENTINEL} SENTINEL failover mymaster + redis-cli -h ${RFS_REDISFAILOVER_SERVICE_HOST} -p ${RFS_REDISFAILOVER_SERVICE_PORT_SENTINEL} SENTINEL failover mymaster fi