mirror of https://github.com/k3s-io/k3s
Merge pull request #629 from erikwilson/update-remotedialer
Update remotedialer & tunnel logspull/635/head
commit
34fc4d0336
|
@ -68,10 +68,12 @@ func Setup(config *config.Node) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
addresses := []string{config.ServerAddress}
|
addresses := []string{config.ServerAddress}
|
||||||
|
endpointResourceVersion := ""
|
||||||
|
|
||||||
endpoint, _ := client.CoreV1().Endpoints("default").Get("kubernetes", metav1.GetOptions{})
|
endpoint, _ := client.CoreV1().Endpoints("default").Get("kubernetes", metav1.GetOptions{})
|
||||||
if endpoint != nil {
|
if endpoint != nil {
|
||||||
addresses = getAddresses(endpoint)
|
addresses = getAddresses(endpoint)
|
||||||
|
endpointResourceVersion = endpoint.ResourceVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect := map[string]context.CancelFunc{}
|
disconnect := map[string]context.CancelFunc{}
|
||||||
|
@ -88,10 +90,11 @@ func Setup(config *config.Node) error {
|
||||||
connect:
|
connect:
|
||||||
for {
|
for {
|
||||||
watch, err := client.CoreV1().Endpoints("default").Watch(metav1.ListOptions{
|
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 {
|
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)
|
time.Sleep(5 * time.Second)
|
||||||
continue connect
|
continue connect
|
||||||
}
|
}
|
||||||
|
@ -100,21 +103,25 @@ func Setup(config *config.Node) error {
|
||||||
select {
|
select {
|
||||||
case ev, ok := <-watch.ResultChan():
|
case ev, ok := <-watch.ResultChan():
|
||||||
if !ok {
|
if !ok {
|
||||||
logrus.Error("endpoint watch channel closed")
|
logrus.Error("Tunnel endpoint watch channel closed")
|
||||||
continue connect
|
continue connect
|
||||||
}
|
}
|
||||||
endpoint, ok := ev.Object.(*v1.Endpoints)
|
endpoint, ok := ev.Object.(*v1.Endpoints)
|
||||||
if !ok {
|
if !ok {
|
||||||
logrus.Error("could not case event object to endpoint")
|
logrus.Error("Tunnel could not case event object to endpoint")
|
||||||
continue watching
|
continue watching
|
||||||
}
|
}
|
||||||
|
endpointResourceVersion = endpoint.ResourceVersion
|
||||||
|
|
||||||
|
var addresses = getAddresses(endpoint)
|
||||||
|
logrus.Infof("Tunnel endpoint watch event: %v", addresses)
|
||||||
|
|
||||||
validEndpoint := map[string]bool{}
|
validEndpoint := map[string]bool{}
|
||||||
var addresses = getAddresses(endpoint)
|
|
||||||
for _, address := range addresses {
|
for _, address := range addresses {
|
||||||
validEndpoint[address] = true
|
validEndpoint[address] = true
|
||||||
if _, ok := disconnect[address]; !ok {
|
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 {
|
if ctx.Err() != nil {
|
||||||
logrus.Infof("Stopping tunnel to %s", wsURL)
|
logrus.Infof("Stopped tunnel to %s", wsURL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -229,7 +229,7 @@ import:
|
||||||
- package: github.com/rancher/helm-controller
|
- package: github.com/rancher/helm-controller
|
||||||
version: v0.2.1
|
version: v0.2.1
|
||||||
- package: github.com/rancher/remotedialer
|
- package: github.com/rancher/remotedialer
|
||||||
version: 66218bc42b4fa27c34523c0d19a41a0e2b74983d
|
version: 4a5a661be67697d6369df54ef62d5a30b0385697
|
||||||
- package: github.com/rancher/wrangler
|
- package: github.com/rancher/wrangler
|
||||||
version: 7737c167e16514a38229bc64c839cee8cd14e6d3
|
version: 7737c167e16514a38229bc64c839cee8cd14e6d3
|
||||||
- package: github.com/rancher/wrangler-api
|
- package: github.com/rancher/wrangler-api
|
||||||
|
|
|
@ -14,7 +14,7 @@ k8s.io/kubernetes v1.14.3-k3s.2 ht
|
||||||
github.com/rancher/wrangler 7737c167e16514a38229bc64c839cee8cd14e6d3
|
github.com/rancher/wrangler 7737c167e16514a38229bc64c839cee8cd14e6d3
|
||||||
github.com/rancher/wrangler-api v0.1.4
|
github.com/rancher/wrangler-api v0.1.4
|
||||||
github.com/rancher/dynamiclistener 4716ac2362986f28bede3f3caf5d1ce347da55b0
|
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/rancher/helm-controller v0.2.1
|
||||||
github.com/matryer/moq ee5226d43009 https://github.com/rancher/moq.git
|
github.com/matryer/moq ee5226d43009 https://github.com/rancher/moq.git
|
||||||
github.com/coreos/flannel 823afe66b2266bf71f5bec24e6e28b26d70cfc7c https://github.com/ibuildthecloud/flannel.git
|
github.com/coreos/flannel 823afe66b2266bf71f5bec24e6e28b26d70cfc7c https://github.com/ibuildthecloud/flannel.git
|
||||||
|
|
|
@ -31,11 +31,11 @@ func connectToProxy(ctx context.Context, proxyURL string, headers http.Header, a
|
||||||
}
|
}
|
||||||
defer ws.Close()
|
defer ws.Close()
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
|
||||||
defer cancel()
|
|
||||||
|
|
||||||
if onConnect != nil {
|
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
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,8 @@ func connectToProxy(ctx context.Context, proxyURL string, headers http.Header, a
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
logrus.WithField("url", proxyURL).WithField("err", ctx.Err()).Info("Proxy done")
|
||||||
|
return nil
|
||||||
case err := <-result:
|
case err := <-result:
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue