1
0
mirror of https://github.com/rancher/rke.git synced 2025-07-18 01:11:25 +00:00

Merge pull request #306 from galal-hussein/custom_dialers_fix

Custom dialers and remove local fixes
This commit is contained in:
Darren Shepherd 2018-02-03 01:13:34 +00:00 committed by GitHub
commit f939a05944
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 6 deletions

View File

@ -98,6 +98,17 @@ func clusterRemoveFromCli(ctx *cli.Context) error {
func clusterRemoveLocal(ctx *cli.Context) error { func clusterRemoveLocal(ctx *cli.Context) error {
var rkeConfig *v3.RancherKubernetesEngineConfig var rkeConfig *v3.RancherKubernetesEngineConfig
clusterFile, filePath, err := resolveClusterFile(ctx)
if err != nil {
log.Infof(context.Background(), "Failed to resolve cluster file, using default cluster instead")
rkeConfig = cluster.GetLocalRKEConfig() rkeConfig = cluster.GetLocalRKEConfig()
} else {
clusterFilePath = filePath
rkeConfig, err = cluster.ParseConfig(clusterFile)
if err != nil {
return fmt.Errorf("Failed to parse cluster file: %v", err)
}
rkeConfig.Nodes = []v3.RKEConfigNode{*cluster.GetLocalRKENodeConfig()}
}
return ClusterRemove(context.Background(), rkeConfig, nil, true, "") return ClusterRemove(context.Background(), rkeConfig, nil, true, "")
} }

View File

@ -73,7 +73,7 @@ func (d *dialer) DialLocalConn(network, addr string) (net.Conn, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to dial ssh using address [%s]: %v", sshAddr, err) return nil, fmt.Errorf("Failed to dial ssh using address [%s]: %v", sshAddr, err)
} }
remote, err := conn.Dial("tcp", fmt.Sprintf("localhost:%d", d.host.LocalConnPort)) remote, err := conn.Dial(network, addr)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to dial to Local Port [%d] on host [%s]: %v", d.host.LocalConnPort, d.host.Address, err) return nil, fmt.Errorf("Failed to dial to Local Port [%d] on host [%s]: %v", d.host.LocalConnPort, d.host.Address, err)
} }

View File

@ -13,7 +13,7 @@ func LocalHealthcheckFactory(h *Host) (func(network, address string) (net.Conn,
} }
func (d *dialer) DialHealthcheckLocally(network, addr string) (net.Conn, error) { func (d *dialer) DialHealthcheckLocally(network, addr string) (net.Conn, error) {
conn, err := net.Dial("tcp", fmt.Sprintf("localhost:%d", d.host.LocalConnPort)) conn, err := net.Dial(network, addr)
if err != nil { if err != nil {
return nil, fmt.Errorf("Failed to dial address [%s]: %v", d.host.Address, err) return nil, fmt.Errorf("Failed to dial address [%s]: %v", d.host.Address, err)
} }

View File

@ -27,7 +27,7 @@ func runHealthcheck(ctx context.Context, host *hosts.Host, port int, useTLS bool
return fmt.Errorf("Failed to initiate new HTTP client for service [%s] for host [%s]", serviceName, host.Address) return fmt.Errorf("Failed to initiate new HTTP client for service [%s] for host [%s]", serviceName, host.Address)
} }
for retries := 0; retries < 10; retries++ { for retries := 0; retries < 10; retries++ {
if err = getHealthz(client, useTLS, serviceName, host.Address); err != nil { if err = getHealthz(client, useTLS, serviceName, host.Address, port); err != nil {
logrus.Debugf("[healthcheck] %v", err) logrus.Debugf("[healthcheck] %v", err)
time.Sleep(5 * time.Second) time.Sleep(5 * time.Second)
continue continue
@ -58,12 +58,12 @@ func getHealthCheckHTTPClient(host *hosts.Host, port int, localConnDialerFactory
}, nil }, nil
} }
func getHealthz(client *http.Client, useTLS bool, serviceName, hostAddress string) error { func getHealthz(client *http.Client, useTLS bool, serviceName, hostAddress string, port int) error {
proto := HTTPProtoPrefix proto := HTTPProtoPrefix
if useTLS { if useTLS {
proto = HTTPSProtoPrefix proto = HTTPSProtoPrefix
} }
resp, err := client.Get(fmt.Sprintf("%s%s%s", proto, HealthzAddress, HealthzEndpoint)) resp, err := client.Get(fmt.Sprintf("%s%s:%d%s", proto, HealthzAddress, port, HealthzEndpoint))
if err != nil { if err != nil {
return fmt.Errorf("Failed to check %s for service [%s] on host [%s]: %v", HealthzEndpoint, serviceName, hostAddress, err) return fmt.Errorf("Failed to check %s for service [%s] on host [%s]: %v", HealthzEndpoint, serviceName, hostAddress, err)
} }