mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 10:33:35 +00:00
vendor update for CSI 0.3.0
This commit is contained in:
14
vendor/k8s.io/kubernetes/pkg/ssh/ssh.go
generated
vendored
14
vendor/k8s.io/kubernetes/pkg/ssh/ssh.go
generated
vendored
@ -18,6 +18,7 @@ package ssh
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/tls"
|
||||
@ -121,10 +122,11 @@ func (s *SSHTunnel) Open() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SSHTunnel) Dial(network, address string) (net.Conn, error) {
|
||||
func (s *SSHTunnel) Dial(ctx context.Context, network, address string) (net.Conn, error) {
|
||||
if s.client == nil {
|
||||
return nil, errors.New("tunnel is not opened.")
|
||||
}
|
||||
// This Dial method does not allow to pass a context unfortunately
|
||||
return s.client.Dial(network, address)
|
||||
}
|
||||
|
||||
@ -294,7 +296,7 @@ func ParsePublicKeyFromFile(keyFile string) (*rsa.PublicKey, error) {
|
||||
type tunnel interface {
|
||||
Open() error
|
||||
Close() error
|
||||
Dial(network, address string) (net.Conn, error)
|
||||
Dial(ctx context.Context, network, address string) (net.Conn, error)
|
||||
}
|
||||
|
||||
type sshTunnelEntry struct {
|
||||
@ -361,7 +363,7 @@ func (l *SSHTunnelList) delayedHealthCheck(e sshTunnelEntry, delay time.Duration
|
||||
func (l *SSHTunnelList) healthCheck(e sshTunnelEntry) error {
|
||||
// GET the healthcheck path using the provided tunnel's dial function.
|
||||
transport := utilnet.SetTransportDefaults(&http.Transport{
|
||||
Dial: e.Tunnel.Dial,
|
||||
DialContext: e.Tunnel.Dial,
|
||||
// TODO(cjcullen): Plumb real TLS options through.
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
// We don't reuse the clients, so disable the keep-alive to properly
|
||||
@ -394,18 +396,18 @@ func (l *SSHTunnelList) removeAndReAdd(e sshTunnelEntry) {
|
||||
go l.createAndAddTunnel(e.Address)
|
||||
}
|
||||
|
||||
func (l *SSHTunnelList) Dial(net, addr string) (net.Conn, error) {
|
||||
func (l *SSHTunnelList) Dial(ctx context.Context, net, addr string) (net.Conn, error) {
|
||||
start := time.Now()
|
||||
id := mathrand.Int63() // So you can match begins/ends in the log.
|
||||
glog.Infof("[%x: %v] Dialing...", id, addr)
|
||||
defer func() {
|
||||
glog.Infof("[%x: %v] Dialed in %v.", id, addr, time.Now().Sub(start))
|
||||
glog.Infof("[%x: %v] Dialed in %v.", id, addr, time.Since(start))
|
||||
}()
|
||||
tunnel, err := l.pickTunnel(strings.Split(addr, ":")[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return tunnel.Dial(net, addr)
|
||||
return tunnel.Dial(ctx, net, addr)
|
||||
}
|
||||
|
||||
func (l *SSHTunnelList) pickTunnel(addr string) (tunnel, error) {
|
||||
|
Reference in New Issue
Block a user