From 0de8baf7170d024dabb51002c2a1d1fd055e10eb Mon Sep 17 00:00:00 2001 From: nexustar Date: Mon, 13 Dec 2021 17:16:35 +0800 Subject: [PATCH 1/2] *: fix slow ssh connect when using buildin ssh (#1664) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a81c271162..ed9af7d91d 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/pingcap/tiup go 1.16 replace ( - github.com/appleboy/easyssh-proxy => github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20210615044136-d52fc631316d + github.com/appleboy/easyssh-proxy => github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20211209071554-9910ebdf514e gopkg.in/yaml.v2 => github.com/july2993/yaml v0.0.0-20200423062752-adcfa5abe2ed ) diff --git a/go.sum b/go.sum index c49b99d7d1..57e4646c6f 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20210615044136-d52fc631316d h1:jsOHh5HJR1sYE1wYxuYQa2nSc01V0/6ZNRIS2qNW1zg= -github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20210615044136-d52fc631316d/go.mod h1:SnOlkuIAoaj8FvRIGcWp2BbLOwvHZnNNOva+DBMbHWU= +github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20211209071554-9910ebdf514e h1:4j6hTmpAhrJYt8XhG/mLJYywzsclH6pqAim1H7HBM/o= +github.com/AstroProfundis/easyssh-proxy v1.3.10-0.20211209071554-9910ebdf514e/go.mod h1:SnOlkuIAoaj8FvRIGcWp2BbLOwvHZnNNOva+DBMbHWU= github.com/AstroProfundis/sysinfo v0.0.0-20210901042104-765f00aa1304 h1:xjoJdgLCgiPv8CNEnsHP+W6UJ/JiNbALll6csqw3hbg= github.com/AstroProfundis/sysinfo v0.0.0-20210901042104-765f00aa1304/go.mod h1:4m15VhW6ZffaqJNAK/HtN3Qvf97aCe1T39u3UXaA2lA= github.com/AstroProfundis/tabby v1.1.1-color h1:gi/Fs4W2KVcC1m29lqa39tDnsGfZG/PYvZmwOhAH5m0= From b01e507a49b188b9aee9cd859ff7a0bc8ac736da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Qi=CE=BC=24hi=D0=AFu=C3=AD?= <39378935+srstack@users.noreply.github.com> Date: Mon, 13 Dec 2021 17:38:36 +0800 Subject: [PATCH 2/2] cluster: support alertmanager configuration Listen Host (#1665) --- embed/templates/scripts/run_alertmanager.sh.tpl | 2 +- pkg/cluster/spec/alertmanager.go | 3 ++- pkg/cluster/spec/spec.go | 1 + pkg/cluster/template/scripts/alertmanager.go | 7 ++++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/embed/templates/scripts/run_alertmanager.sh.tpl b/embed/templates/scripts/run_alertmanager.sh.tpl index 19a362f905..e7925035fc 100644 --- a/embed/templates/scripts/run_alertmanager.sh.tpl +++ b/embed/templates/scripts/run_alertmanager.sh.tpl @@ -26,4 +26,4 @@ exec bin/alertmanager/alertmanager \ --cluster.peer="{{$am.IP}}:{{$am.ClusterPort}}" \ {{- end}} {{- end}} - --cluster.listen-address="{{.IP}}:{{.ClusterPort}}" + --cluster.listen-address="{{.ListenHost}}:{{.ClusterPort}}" diff --git a/pkg/cluster/spec/alertmanager.go b/pkg/cluster/spec/alertmanager.go index a3324a89d8..14c5dc528e 100644 --- a/pkg/cluster/spec/alertmanager.go +++ b/pkg/cluster/spec/alertmanager.go @@ -35,6 +35,7 @@ type AlertmanagerSpec struct { IgnoreExporter bool `yaml:"ignore_exporter,omitempty"` WebPort int `yaml:"web_port" default:"9093"` ClusterPort int `yaml:"cluster_port" default:"9094"` + ListenHost string `yaml:"listen_host,omitempty" validate:"listen_host:editable"` DeployDir string `yaml:"deploy_dir,omitempty"` DataDir string `yaml:"data_dir,omitempty"` LogDir string `yaml:"log_dir,omitempty"` @@ -144,7 +145,7 @@ func (i *AlertManagerInstance) InitConfig( enableTLS := gOpts.TLSEnabled // Transfer start script spec := i.InstanceSpec.(*AlertmanagerSpec) - cfg := scripts.NewAlertManagerScript(spec.Host, paths.Deploy, paths.Data[0], paths.Log, enableTLS). + cfg := scripts.NewAlertManagerScript(spec.Host, spec.ListenHost, paths.Deploy, paths.Data[0], paths.Log, enableTLS). WithWebPort(spec.WebPort).WithClusterPort(spec.ClusterPort).WithNumaNode(spec.NumaNode). AppendEndpoints(AlertManagerEndpoints(alertmanagers, deployUser, enableTLS)) diff --git a/pkg/cluster/spec/spec.go b/pkg/cluster/spec/spec.go index 73a6533f0c..6d3e73afae 100644 --- a/pkg/cluster/spec/spec.go +++ b/pkg/cluster/spec/spec.go @@ -773,6 +773,7 @@ func AlertManagerEndpoints(alertmanager []*AlertmanagerSpec, user string, enable script := scripts.NewAlertManagerScript( spec.Host, + spec.ListenHost, deployDir, dataDir, logDir, diff --git a/pkg/cluster/template/scripts/alertmanager.go b/pkg/cluster/template/scripts/alertmanager.go index ba6667dd23..70bab93015 100644 --- a/pkg/cluster/template/scripts/alertmanager.go +++ b/pkg/cluster/template/scripts/alertmanager.go @@ -25,6 +25,7 @@ import ( // AlertManagerScript represent the data to generate AlertManager start script type AlertManagerScript struct { IP string + ListenHost string WebPort int ClusterPort int DeployDir string @@ -36,9 +37,13 @@ type AlertManagerScript struct { } // NewAlertManagerScript returns a AlertManagerScript with given arguments -func NewAlertManagerScript(ip, deployDir, dataDir, logDir string, enableTLS bool) *AlertManagerScript { +func NewAlertManagerScript(ip, listenHost, deployDir, dataDir, logDir string, enableTLS bool) *AlertManagerScript { + if listenHost == "" { + listenHost = ip + } return &AlertManagerScript{ IP: ip, + ListenHost: listenHost, WebPort: 9093, ClusterPort: 9094, DeployDir: deployDir,