From 9d137ba88cbdbe89161e0eb56a623709ce934b0c Mon Sep 17 00:00:00 2001 From: runkecheng <1131648942@qq.com> Date: Mon, 27 Dec 2021 15:39:51 +0800 Subject: [PATCH] sidecar: Remove the old role tag setting method. #330 --- sidecar/config.go | 22 ---------------------- sidecar/init.go | 26 +++++++++++++------------- sidecar/util.go | 4 ++-- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/sidecar/config.go b/sidecar/config.go index 35dd4a0d4..688c1f288 100644 --- a/sidecar/config.go +++ b/sidecar/config.go @@ -345,8 +345,6 @@ func (cfg *Config) buildXenonConf() []byte { "admit-defeat-hearbeat-count": %d, "heartbeat-timeout": %d, "meta-datadir": "/var/lib/xenon/", - "leader-start-command": "/scripts/leader-start.sh", - "leader-stop-command": "/scripts/leader-stop.sh", "semi-sync-degrade": true, "purge-binlog-disabled": true, "super-idle": false @@ -408,26 +406,6 @@ func (cfg *Config) buildClientConfig() (*ini.File, error) { return conf, nil } -// buildLeaderStart build the leader-start.sh. -func (cfg *Config) buildLeaderStart() []byte { - str := fmt.Sprintf(`#!/usr/bin/env bash -curl -X PATCH -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" \ ---cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/%s/pods/$HOSTNAME \ --d '[{"op": "replace", "path": "/metadata/labels/role", "value": "leader"}]' -`, cfg.NameSpace) - return utils.StringToBytes(str) -} - -// buildLeaderStop build the leader-stop.sh. -func (cfg *Config) buildLeaderStop() []byte { - str := fmt.Sprintf(`#!/usr/bin/env bash -curl -X PATCH -H "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token)" -H "Content-Type: application/json-patch+json" \ ---cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt https://$KUBERNETES_SERVICE_HOST:$KUBERNETES_PORT_443_TCP_PORT/api/v1/namespaces/%s/pods/$HOSTNAME \ --d '[{"op": "replace", "path": "/metadata/labels/role", "value": "follower"}]' -`, cfg.NameSpace) - return utils.StringToBytes(str) -} - /* The function is equivalent to the following shell script template: #!/bin/sh if [ ! -d {{.DataDir}} ] ; then diff --git a/sidecar/init.go b/sidecar/init.go index 8929c1dc3..e41466dfd 100644 --- a/sidecar/init.go +++ b/sidecar/init.go @@ -177,19 +177,19 @@ func runInitCommand(cfg *Config) error { return fmt.Errorf("failed to save extra.cnf: %s", err) } - // build leader-start.sh. - bashLeaderStart := cfg.buildLeaderStart() - leaderStartPath := path.Join(scriptsPath, "leader-start.sh") - if err = ioutil.WriteFile(leaderStartPath, bashLeaderStart, os.FileMode(0755)); err != nil { - return fmt.Errorf("failed to write leader-start.sh: %s", err) - } - - // build leader-stop.sh. - bashLeaderStop := cfg.buildLeaderStop() - leaderStopPath := path.Join(scriptsPath, "leader-stop.sh") - if err = ioutil.WriteFile(leaderStopPath, bashLeaderStop, os.FileMode(0755)); err != nil { - return fmt.Errorf("failed to write leader-stop.sh: %s", err) - } + // // build leader-start.sh. + // bashLeaderStart := cfg.buildLeaderStart() + // leaderStartPath := path.Join(scriptsPath, "leader-start.sh") + // if err = ioutil.WriteFile(leaderStartPath, bashLeaderStart, os.FileMode(0755)); err != nil { + // return fmt.Errorf("failed to write leader-start.sh: %s", err) + // } + + // // build leader-stop.sh. + // bashLeaderStop := cfg.buildLeaderStop() + // leaderStopPath := path.Join(scriptsPath, "leader-stop.sh") + // if err = ioutil.WriteFile(leaderStopPath, bashLeaderStop, os.FileMode(0755)); err != nil { + // return fmt.Errorf("failed to write leader-stop.sh: %s", err) + // } // for install tokudb. if cfg.InitTokuDB { diff --git a/sidecar/util.go b/sidecar/util.go index d3ef01db8..cfbf140b6 100644 --- a/sidecar/util.go +++ b/sidecar/util.go @@ -46,8 +46,8 @@ var ( // dataPath is the mysql data path. dataPath = utils.DataVolumeMountPath - // scriptsPath is the scripts path used for xenon. - scriptsPath = utils.ScriptsVolumeMountPath + // // scriptsPath is the scripts path used for xenon. + // scriptsPath = utils.ScriptsVolumeMountPath // sysPath is the linux kernel path used for install tokudb. sysPath = utils.SysVolumeMountPath