Commit 7e6664b6 authored by Erik Wilson's avatar Erik Wilson

Add resource version to tunnel endpoint watch

parent 034a8636
...@@ -68,10 +68,12 @@ func Setup(config *config.Node) error { ...@@ -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,7 +90,8 @@ func Setup(config *config.Node) error { ...@@ -88,7 +90,8 @@ 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 tunnel endpoints: %v", err) logrus.Errorf("Unable to watch for tunnel endpoints: %v", err)
...@@ -108,6 +111,7 @@ func Setup(config *config.Node) error { ...@@ -108,6 +111,7 @@ func Setup(config *config.Node) error {
logrus.Error("Tunnel 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) var addresses = getAddresses(endpoint)
logrus.Infof("Tunnel endpoint watch event: %v", addresses) logrus.Infof("Tunnel endpoint watch event: %v", addresses)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment