Skip to content

Commit

Permalink
Merge pull request #372 from zekena2/master
Browse files Browse the repository at this point in the history
shutdown script environment variable fix
  • Loading branch information
ese authored Feb 16, 2022
2 parents c23e036 + 994cb73 commit 494cb8a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions example/redisfailover/custom-shutdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 5 additions & 3 deletions operator/redisfailover/service/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package service

import (
"fmt"
"strings"

"bytes"

Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 494cb8a

Please sign in to comment.