@@ -326,6 +326,7 @@ func (cfg *Config) buildXenonConf() []byte {
326
326
hostName := fmt .Sprintf ("%s.%s.%s" , cfg .HostName , cfg .ServiceName , cfg .NameSpace )
327
327
// Because go-sql-driver will translate localhost to 127.0.0.1 or ::1, but never set the hostname
328
328
// so the host is set to "127.0.0.1" in config file.
329
+
329
330
str := fmt .Sprintf (`{
330
331
"log": {
331
332
"level": "INFO"
@@ -363,8 +364,8 @@ func (cfg *Config) buildXenonConf() []byte {
363
364
"semi-sync-degrade": true,
364
365
"purge-binlog-disabled": true,
365
366
"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 "
368
369
}
369
370
}
370
371
` , hostName , utils .XenonPort , hostName , utils .XenonPeerPort , cfg .ReplicationPassword , cfg .ReplicationUser ,
@@ -459,15 +460,13 @@ func (cfg *Config) buildClientConfig() (*ini.File, error) {
459
460
// return utils.StringToBytes(str)
460
461
// }
461
462
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
+ }
471
470
472
471
/* The function is equivalent to the following shell script template:
473
472
#!/bin/sh
0 commit comments