@@ -32,6 +32,9 @@ import (
3232 "k8s.io/client-go/rest"
3333)
3434
35+ var roleChangeCmd = []string {"patronictl" , "edit-config" , "--force" ,
36+ "--set" , "tags.primary_on_role_change=null" }
37+
3538// RemovePrimaryOnRoleChangeTag sets the 'primary_on_role_change' tag to null in the
3639// Patroni DCS, effectively removing the tag. This is accomplished by exec'ing into
3740// the primary PG pod, and sending a patch request to update the appropriate data (i.e.
@@ -61,17 +64,11 @@ func RemovePrimaryOnRoleChangeTag(clientset kubernetes.Interface, restconfig *re
6164 }
6265 pod := pods .Items [0 ]
6366
64- // generate the curl command that will be run on the pod selected for the failover in order
65- // to trigger the failover and promote that specific pod to primary
66- command := make ([]string , 3 )
67- command [0 ] = "/bin/bash"
68- command [1 ] = "-c"
69- command [2 ] = fmt .Sprintf ("curl -s 127.0.0.1:%s/config -XPATCH -d " +
70- "'{\" tags\" :{\" primary_on_role_change\" :null}}'" , config .DEFAULT_PATRONI_PORT )
71-
67+ // execute the command that will be run on the pod selected for the failover
68+ // in order to trigger the failover and promote that specific pod to primary
7269 log .Debugf ("running Exec command '%s' with namespace=[%s] podname=[%s] container name=[%s]" ,
73- command , namespace , pod .Name , pod .Spec .Containers [0 ].Name )
74- stdout , stderr , err := kubeapi .ExecToPodThroughAPI (restconfig , clientset , command ,
70+ roleChangeCmd , namespace , pod .Name , pod .Spec .Containers [0 ].Name )
71+ stdout , stderr , err := kubeapi .ExecToPodThroughAPI (restconfig , clientset , roleChangeCmd ,
7572 pod .Spec .Containers [0 ].Name , pod .Name , namespace , nil )
7673 log .Debugf ("stdout=[%s] stderr=[%s]" , stdout , stderr )
7774 if err != nil {
0 commit comments