Skip to content

Commit 7246c65

Browse files
joakimkp-wall
authored andcommitted
Fixing naming issues that prevented this from working on our cluster
Why is there these differences? Different verisons of spotahome or just configured differently?
1 parent 5764cd9 commit 7246c65

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

k

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2669,7 +2669,7 @@ def redis_failover
26692669
redis_cluster = ARGV.delete_at(0)
26702670
abort "Must pass name of redis cluster, eg. k redis:failover <cluster-name>" unless redis_cluster
26712671

2672-
if kubectl?("get redisfailover #{redis_cluster}-redis")
2672+
if kubectl?("get redisfailovers.databases.spotahome.com #{redis_cluster} -o yaml")
26732673
# We're using Spotahome's Redis Operator
26742674

26752675
# Remember current master pod for eviction later on
@@ -2681,12 +2681,12 @@ def redis_failover
26812681
abort "Error: no master pod name found in endpoint YAML for #{redis_cluster}-redis-master" unless master_pod
26822682

26832683
# Use Sentinel to failover
2684-
sentinel_endpoint_yaml = read_kubectl "get endpoints/rfs-#{redis_cluster}-redis --ignore-not-found -o yaml"
2685-
abort "Error: no sentinel endpoint found for #{redis_cluster} (looked for rfs-#{redis_cluster}-redis)" if sentinel_endpoint_yaml.empty?
2684+
sentinel_endpoint_yaml = read_kubectl "get endpoints/rfs-#{redis_cluster} --ignore-not-found -o yaml"
2685+
abort "Error: no sentinel endpoint found for #{redis_cluster} (looked for rfs-#{redis_cluster})" if sentinel_endpoint_yaml.empty?
26862686

26872687
sentinel_endpoint = YAML.safe_load(sentinel_endpoint_yaml)
26882688
sentinel_pod = sentinel_endpoint.dig("subsets", 0, "addresses", 0, "targetRef", "name")
2689-
abort "Error: no sentinel pod name found in endpoint YAML for rfs-#{redis_cluster}-redis" unless sentinel_pod
2689+
abort "Error: no sentinel pod name found in endpoint YAML for rfs-#{redis_cluster}" unless sentinel_pod
26902690

26912691
puts "Running redis-cli with SENTINEL FAILOVER command on #{sentinel_pod}..."
26922692
kubectl("exec -c sentinel -it #{sentinel_pod} -- redis-cli -p 26379 SENTINEL FAILOVER mymaster") or abort("Error: failed to failover master")

0 commit comments

Comments
 (0)