Skip to content

Commit

Permalink
We still rely on redis-cli from the host though
Browse files Browse the repository at this point in the history
  • Loading branch information
mickenordin committed Mar 21, 2024
1 parent e4bd1b9 commit 5e03ad6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion templates/keydbcluster/11-keydbcluster.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

echo "Checking KeyDB cluster status,please standby..."
cluster_status=$(keydb-cli -a "$(puppet lookup --render-as s keydb_password 2>/dev/null)" --tls --cert /etc/ssl/certs/$(hostname -f)_infra.crt --key /etc/ssl/private/$(hostname -f)_infra.key --cacert /etc/ssl/certs/infra.crt -h $(hostname -f) cluster nodes 2> /dev/null)
cluster_status=$(redis-cli -a "$(puppet lookup --render-as s keydb_password 2>/dev/null)" --tls --cert /etc/ssl/certs/$(hostname -f)_infra.crt --key /etc/ssl/private/$(hostname -f)_infra.key --cacert /etc/ssl/certs/infra.crt -h $(hostname -f) cluster nodes 2> /dev/null)

my_ip=$(echo "${cluster_status}" | grep myself, | awk '{print $2}' | cut -d : -f 1)

Expand Down
6 changes: 3 additions & 3 deletions templates/keydbcluster/keydb-rectify.sh.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ cert="/etc/ssl/certs/${fqdn}_infra.crt"
key="/etc/ssl/private/${fqdn}_infra.key"
ca="/etc/ssl/certs/infra.crt"
password=$(puppet lookup --render-as s keydb_password 2> /dev/null)
clusterid=$(keydb-cli -a "${password}" -h "${fqdn}" --tls --cert "${cert}" --key "${key}" --cacert "${ca}" CLUSTER MYID 2> /dev/null)
if (keydb-cli -a "${password}" -h "${fqdn}" --tls --cert "${cert}" --key "${key}" --cacert "${ca}" CLUSTER NODES 2> /dev/null| grep -e "^${clusterid}"| grep -q slave); then
clusterid=$(redis-cli -a "${password}" -h "${fqdn}" --tls --cert "${cert}" --key "${key}" --cacert "${ca}" CLUSTER MYID 2> /dev/null)
if (redis-cli -a "${password}" -h "${fqdn}" --tls --cert "${cert}" --key "${key}" --cacert "${ca}" CLUSTER NODES 2> /dev/null| grep -e "^${clusterid}"| grep -q slave); then
echo SLAVE, failing over to master
if [ "${dryrun}" ]; then
echo "No failover will happen in dryrun"
Expand All @@ -29,7 +29,7 @@ if (keydb-cli -a "${password}" -h "${fqdn}" --tls --cert "${cert}" --key "${key}
if [ -f "${lock_file}" ] && [ "${force}" -ne 1 ]; then
echo "Host is in maintainace mode (by ${lock_file}). No failover will happen."
else
keydb-cli -a "${password}" -h "${fqdn}" --tls --cert "${cert}" --key "${key}" --cacert "${ca}" CLUSTER FAILOVER 2> /dev/null
redis-cli -a "${password}" -h "${fqdn}" --tls --cert "${cert}" --key "${key}" --cacert "${ca}" CLUSTER FAILOVER 2> /dev/null
fi
else
echo "Node is MASTER, all is good."
Expand Down

0 comments on commit 5e03ad6

Please sign in to comment.