Skip to content

Commit a5d6d9f

Browse files
committed
sidecar: Remove the old role tag setting method. #330
1 parent e7d8f16 commit a5d6d9f

File tree

3 files changed

+34
-36
lines changed

3 files changed

+34
-36
lines changed

sidecar/config.go

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,6 @@ func (cfg *Config) buildXenonConf() []byte {
345345
"admit-defeat-hearbeat-count": %d,
346346
"heartbeat-timeout": %d,
347347
"meta-datadir": "/var/lib/xenon/",
348-
"leader-start-command": "/scripts/leader-start.sh",
349-
"leader-stop-command": "/scripts/leader-stop.sh",
350348
"semi-sync-degrade": true,
351349
"purge-binlog-disabled": true,
352350
"super-idle": false
@@ -408,25 +406,25 @@ func (cfg *Config) buildClientConfig() (*ini.File, error) {
408406
return conf, nil
409407
}
410408

411-
// buildLeaderStart build the leader-start.sh.
412-
func (cfg *Config) buildLeaderStart() []byte {
413-
str := fmt.Sprintf(`#!/usr/bin/env bash
414-
curl -X PATCH -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" \
415-
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/%s/pods/$HOSTNAME \
416-
-d '[{"op": "replace", "path": "/metadata/labels/role", "value": "leader"}]'
417-
`, cfg.NameSpace)
418-
return utils.StringToBytes(str)
419-
}
420-
421-
// buildLeaderStop build the leader-stop.sh.
422-
func (cfg *Config) buildLeaderStop() []byte {
423-
str := fmt.Sprintf(`#!/usr/bin/env bash
424-
curl -X PATCH -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" \
425-
--cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/%s/pods/$HOSTNAME \
426-
-d '[{"op": "replace", "path": "/metadata/labels/role", "value": "follower"}]'
427-
`, cfg.NameSpace)
428-
return utils.StringToBytes(str)
429-
}
409+
// // buildLeaderStart build the leader-start.sh.
410+
// func (cfg *Config) buildLeaderStart() []byte {
411+
// str := fmt.Sprintf(`#!/usr/bin/env bash
412+
// curl -X PATCH -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" \
413+
// --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/%s/pods/$HOSTNAME \
414+
// -d '[{"op": "replace", "path": "/metadata/labels/role", "value": "leader"}]'
415+
// `, cfg.NameSpace)
416+
// return utils.StringToBytes(str)
417+
// }
418+
419+
// // buildLeaderStop build the leader-stop.sh.
420+
// func (cfg *Config) buildLeaderStop() []byte {
421+
// str := fmt.Sprintf(`#!/usr/bin/env bash
422+
// curl -X PATCH -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" \
423+
// --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/%s/pods/$HOSTNAME \
424+
// -d '[{"op": "replace", "path": "/metadata/labels/role", "value": "follower"}]'
425+
// `, cfg.NameSpace)
426+
// return utils.StringToBytes(str)
427+
// }
430428

431429
/* The function is equivalent to the following shell script template:
432430
#!/bin/sh

sidecar/init.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,19 @@ func runInitCommand(cfg *Config) error {
177177
return fmt.Errorf("failed to save extra.cnf: %s", err)
178178
}
179179

180-
// build leader-start.sh.
181-
bashLeaderStart := cfg.buildLeaderStart()
182-
leaderStartPath := path.Join(scriptsPath, "leader-start.sh")
183-
if err = ioutil.WriteFile(leaderStartPath, bashLeaderStart, os.FileMode(0755)); err != nil {
184-
return fmt.Errorf("failed to write leader-start.sh: %s", err)
185-
}
186-
187-
// build leader-stop.sh.
188-
bashLeaderStop := cfg.buildLeaderStop()
189-
leaderStopPath := path.Join(scriptsPath, "leader-stop.sh")
190-
if err = ioutil.WriteFile(leaderStopPath, bashLeaderStop, os.FileMode(0755)); err != nil {
191-
return fmt.Errorf("failed to write leader-stop.sh: %s", err)
192-
}
180+
// // build leader-start.sh.
181+
// bashLeaderStart := cfg.buildLeaderStart()
182+
// leaderStartPath := path.Join(scriptsPath, "leader-start.sh")
183+
// if err = ioutil.WriteFile(leaderStartPath, bashLeaderStart, os.FileMode(0755)); err != nil {
184+
// return fmt.Errorf("failed to write leader-start.sh: %s", err)
185+
// }
186+
187+
// // build leader-stop.sh.
188+
// bashLeaderStop := cfg.buildLeaderStop()
189+
// leaderStopPath := path.Join(scriptsPath, "leader-stop.sh")
190+
// if err = ioutil.WriteFile(leaderStopPath, bashLeaderStop, os.FileMode(0755)); err != nil {
191+
// return fmt.Errorf("failed to write leader-stop.sh: %s", err)
192+
// }
193193

194194
// for install tokudb.
195195
if cfg.InitTokuDB {

sidecar/util.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ var (
4646
// dataPath is the mysql data path.
4747
dataPath = utils.DataVolumeMountPath
4848

49-
// scriptsPath is the scripts path used for xenon.
50-
scriptsPath = utils.ScriptsVolumeMountPath
49+
// // scriptsPath is the scripts path used for xenon.
50+
// scriptsPath = utils.ScriptsVolumeMountPath
5151

5252
// sysPath is the linux kernel path used for install tokudb.
5353
sysPath = utils.SysVolumeMountPath

0 commit comments

Comments
 (0)