@@ -326,6 +326,7 @@ func (cfg *Config) buildXenonConf() []byte {
326326 hostName := fmt .Sprintf ("%s.%s.%s" , cfg .HostName , cfg .ServiceName , cfg .NameSpace )
327327 // Because go-sql-driver will translate localhost to 127.0.0.1 or ::1, but never set the hostname
328328 // so the host is set to "127.0.0.1" in config file.
329+
329330 str := fmt .Sprintf (`{
330331 "log": {
331332 "level": "INFO"
@@ -363,8 +364,8 @@ func (cfg *Config) buildXenonConf() []byte {
363364 "semi-sync-degrade": true,
364365 "purge-binlog-disabled": true,
365366 "super-idle": false,
366- "leader-start-command": "/xenonchecker leaderStart ",
367- "leader-stop-command": "/xenonchecker leaderStop "
367+ "leader-start-command": "/scripts/leader-stop.sh ",
368+ "leader-stop-command": "/scripts/leader-stop.sh "
368369 }
369370 }
370371 ` , hostName , utils .XenonPort , hostName , utils .XenonPeerPort , cfg .ReplicationPassword , cfg .ReplicationUser ,
@@ -459,15 +460,13 @@ func (cfg *Config) buildClientConfig() (*ini.File, error) {
459460// return utils.StringToBytes(str)
460461// }
461462
462- // // buildLeaderStop build the leader-stop.sh.
463- // func (cfg *Config) buildLeaderStop() []byte {
464- // str := fmt.Sprintf(`#!/usr/bin/env bash
465- // curl -X PATCH -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" \
466- // --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/%s/pods/$HOSTNAME \
467- // -d '[{"op": "replace", "path": "/metadata/labels/role", "value": "follower"}]'
468- // `, cfg.NameSpace)
469- // return utils.StringToBytes(str)
470- // }
463+ // buildLeaderStop build the leader-stop.sh.
464+ func (cfg * Config ) buildLeaderStop () []byte {
465+ str := fmt .Sprintf (`#!/usr/bin/env bash
466+ curl -X DELETE -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json" --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/$NAMESPACE/services/%s-leader
467+ ` , cfg .ClusterName )
468+ return utils .StringToBytes (str )
469+ }
471470
472471/* The function is equivalent to the following shell script template:
473472#!/bin/sh
0 commit comments