Merge pull request #629 from erikwilson/update-remotedialer

Update remotedialer & tunnel logs
This commit is contained in:
Erik Wilson 2019-07-12 16:22:10 -07:00 committed by GitHub
commit 34fc4d0336
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 14 deletions

View File

@ -68,10 +68,12 @@ func Setup(config *config.Node) error {
}
addresses := []string{config.ServerAddress}
endpointResourceVersion := ""
endpoint, _ := client.CoreV1().Endpoints("default").Get("kubernetes", metav1.GetOptions{})
if endpoint != nil {
addresses = getAddresses(endpoint)
endpointResourceVersion = endpoint.ResourceVersion
}
disconnect := map[string]context.CancelFunc{}
@ -88,10 +90,11 @@ func Setup(config *config.Node) error {
connect:
for {
watch, err := client.CoreV1().Endpoints("default").Watch(metav1.ListOptions{
FieldSelector: fields.Set{"metadata.name": "kubernetes"}.String(),
FieldSelector: fields.Set{"metadata.name": "kubernetes"}.String(),
ResourceVersion: endpointResourceVersion,
})
if err != nil {
logrus.Errorf("Unable to watch for endpoints: %v", err)
logrus.Errorf("Unable to watch for tunnel endpoints: %v", err)
time.Sleep(5 * time.Second)
continue connect
}
@ -100,21 +103,25 @@ func Setup(config *config.Node) error {
select {
case ev, ok := <-watch.ResultChan():
if !ok {
logrus.Error("endpoint watch channel closed")
logrus.Error("Tunnel endpoint watch channel closed")
continue connect
}
endpoint, ok := ev.Object.(*v1.Endpoints)
if !ok {
logrus.Error("could not case event object to endpoint")
logrus.Error("Tunnel could not case event object to endpoint")
continue watching
}
endpointResourceVersion = endpoint.ResourceVersion
var addresses = getAddresses(endpoint)
logrus.Infof("Tunnel endpoint watch event: %v", addresses)
validEndpoint := map[string]bool{}
var addresses = getAddresses(endpoint)
for _, address := range addresses {
validEndpoint[address] = true
if _, ok := disconnect[address]; !ok {
disconnect[address] = connect(wg, address, config, transportConfig)
disconnect[address] = connect(nil, address, config, transportConfig)
}
}
@ -173,7 +180,7 @@ func connect(waitGroup *sync.WaitGroup, address string, config *config.Node, tra
})
if ctx.Err() != nil {
logrus.Infof("Stopping tunnel to %s", wsURL)
logrus.Infof("Stopped tunnel to %s", wsURL)
return
}
}

View File

@ -229,7 +229,7 @@ import:
- package: github.com/rancher/helm-controller
version: v0.2.1
- package: github.com/rancher/remotedialer
version: 66218bc42b4fa27c34523c0d19a41a0e2b74983d
version: 4a5a661be67697d6369df54ef62d5a30b0385697
- package: github.com/rancher/wrangler
version: 7737c167e16514a38229bc64c839cee8cd14e6d3
- package: github.com/rancher/wrangler-api

View File

@ -14,7 +14,7 @@ k8s.io/kubernetes v1.14.3-k3s.2 ht
github.com/rancher/wrangler 7737c167e16514a38229bc64c839cee8cd14e6d3
github.com/rancher/wrangler-api v0.1.4
github.com/rancher/dynamiclistener 4716ac2362986f28bede3f3caf5d1ce347da55b0
github.com/rancher/remotedialer 66218bc42b4fa27c34523c0d19a41a0e2b74983d
github.com/rancher/remotedialer 4a5a661be67697d6369df54ef62d5a30b0385697
github.com/rancher/helm-controller v0.2.1
github.com/matryer/moq ee5226d43009 https://github.com/rancher/moq.git
github.com/coreos/flannel 823afe66b2266bf71f5bec24e6e28b26d70cfc7c https://github.com/ibuildthecloud/flannel.git

View File

@ -31,11 +31,11 @@ func connectToProxy(ctx context.Context, proxyURL string, headers http.Header, a
}
defer ws.Close()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
if onConnect != nil {
if err := onConnect(ctx); err != nil {
ctxOnConnect, cancel := context.WithCancel(context.Background())
defer cancel()
if err := onConnect(ctxOnConnect); err != nil {
return err
}
}
@ -51,7 +51,8 @@ func connectToProxy(ctx context.Context, proxyURL string, headers http.Header, a
select {
case <-ctx.Done():
return ctx.Err()
logrus.WithField("url", proxyURL).WithField("err", ctx.Err()).Info("Proxy done")
return nil
case err := <-result:
return err
}