From c18e896ab912ada5132d9ec6e5115b77b8c4a128 Mon Sep 17 00:00:00 2001 From: Erik Wilson Date: Wed, 10 Jul 2019 14:49:56 -0700 Subject: [PATCH 1/3] Update remotedialer vendor --- trash.lock | 2 +- vendor.conf | 2 +- vendor/github.com/rancher/remotedialer/client.go | 11 ++++++----- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/trash.lock b/trash.lock index a88cfbc277..1a56bff84d 100755 --- a/trash.lock +++ b/trash.lock @@ -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 diff --git a/vendor.conf b/vendor.conf index f17a254ae8..e187dfb76a 100644 --- a/vendor.conf +++ b/vendor.conf @@ -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 diff --git a/vendor/github.com/rancher/remotedialer/client.go b/vendor/github.com/rancher/remotedialer/client.go index 48eefc9d7d..d56635e5f0 100644 --- a/vendor/github.com/rancher/remotedialer/client.go +++ b/vendor/github.com/rancher/remotedialer/client.go @@ -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 } From 034a8636968cac290969de0eb34b0ec3c93af0c5 Mon Sep 17 00:00:00 2001 From: Erik Wilson Date: Wed, 10 Jul 2019 14:50:23 -0700 Subject: [PATCH 2/3] Cleanup remotedialer tunnel logs --- pkg/agent/tunnel/tunnel.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/agent/tunnel/tunnel.go b/pkg/agent/tunnel/tunnel.go index 648702f212..55beda66d5 100644 --- a/pkg/agent/tunnel/tunnel.go +++ b/pkg/agent/tunnel/tunnel.go @@ -91,7 +91,7 @@ func Setup(config *config.Node) error { FieldSelector: fields.Set{"metadata.name": "kubernetes"}.String(), }) 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 +100,24 @@ 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 } - validEndpoint := map[string]bool{} var addresses = getAddresses(endpoint) + logrus.Infof("Tunnel endpoint watch event: %v", addresses) + + validEndpoint := map[string]bool{} + 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 +176,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 } } From 7e6664b684f8a3b40e3f1c2d2eb250a53ce4f12f Mon Sep 17 00:00:00 2001 From: Erik Wilson Date: Fri, 12 Jul 2019 15:35:39 -0700 Subject: [PATCH 3/3] Add resource version to tunnel endpoint watch --- pkg/agent/tunnel/tunnel.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/agent/tunnel/tunnel.go b/pkg/agent/tunnel/tunnel.go index 55beda66d5..68f11e7702 100644 --- a/pkg/agent/tunnel/tunnel.go +++ b/pkg/agent/tunnel/tunnel.go @@ -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,7 +90,8 @@ 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 tunnel endpoints: %v", err) @@ -108,6 +111,7 @@ func Setup(config *config.Node) error { 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)