diff --git a/changelog/unreleased/update-go-micro-kubernetes-registry-to-a179a6b8.md b/changelog/unreleased/update-go-micro-kubernetes-registry-to-a179a6b8.md new file mode 100644 index 00000000000..cda54f6ee43 --- /dev/null +++ b/changelog/unreleased/update-go-micro-kubernetes-registry-to-a179a6b8.md @@ -0,0 +1,5 @@ +Enhancement: Update go-micro kubernetes registry + +https://github.com/owncloud/ocis/pull/6457 +https://github.com/go-micro/plugins/pull/114 +https://github.com/go-micro/plugins/pull/113 diff --git a/go.mod b/go.mod index 7c0a0b58bb8..4c8076bc333 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/go-micro/plugins/v4/logger/zerolog v1.2.0 github.com/go-micro/plugins/v4/registry/consul v1.2.0 github.com/go-micro/plugins/v4/registry/etcd v1.2.0 - github.com/go-micro/plugins/v4/registry/kubernetes v1.1.1 + github.com/go-micro/plugins/v4/registry/kubernetes v1.1.2-0.20230605104008-a179a6b8f8e6 github.com/go-micro/plugins/v4/registry/mdns v1.2.0 github.com/go-micro/plugins/v4/registry/memory v1.2.0 github.com/go-micro/plugins/v4/registry/nats v1.2.1 diff --git a/go.sum b/go.sum index 1fadeecb701..e0cfe0ea594 100644 --- a/go.sum +++ b/go.sum @@ -782,8 +782,8 @@ github.com/go-micro/plugins/v4/registry/consul v1.2.0 h1:nqrTzfWUTWKAy+M+i2FazbH github.com/go-micro/plugins/v4/registry/consul v1.2.0/go.mod h1:wTat7/K9XQ+i64VbbcMYFcEwipYfSgJM51HcA/sgsM4= github.com/go-micro/plugins/v4/registry/etcd v1.2.0 h1:tcHlU1GzvX3oZa8WQH8ylMCGie5qD5g98YWTESJjeqQ= github.com/go-micro/plugins/v4/registry/etcd v1.2.0/go.mod h1:CQeTHkjN3xMtIQsynaTTquMz2sHEdsTfRIfFzrX7aug= -github.com/go-micro/plugins/v4/registry/kubernetes v1.1.1 h1:nzwyyK2JKJtmJ8w0CRn9zsn4+kwJitx8CYfAWH99eiI= -github.com/go-micro/plugins/v4/registry/kubernetes v1.1.1/go.mod h1:u78+qWLUq8jxu/CF4UW+1UUtNgBz67x27ar2kV5Dd/o= +github.com/go-micro/plugins/v4/registry/kubernetes v1.1.2-0.20230605104008-a179a6b8f8e6 h1:ekJ70Hq3N+Enz71GCubzhzcVuA9jfd1zWuqTXZF+UlU= +github.com/go-micro/plugins/v4/registry/kubernetes v1.1.2-0.20230605104008-a179a6b8f8e6/go.mod h1:u78+qWLUq8jxu/CF4UW+1UUtNgBz67x27ar2kV5Dd/o= github.com/go-micro/plugins/v4/registry/mdns v1.2.0 h1:BsGnco+PgycvSX+HS0XbeUQEPoPT3a+dDiHWV6dbVDs= github.com/go-micro/plugins/v4/registry/mdns v1.2.0/go.mod h1:re0JvO5F56n59WEDaAKj2jtboKa2dklAd6iWyz5xa54= github.com/go-micro/plugins/v4/registry/memory v1.2.0 h1:R0G2tltffuG+fQnk+/JuAdgEJX4J+LuOafZDoNd8ow0= diff --git a/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/client/watch/body.go b/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/client/watch/body.go index b93e222dca3..4570a3e8de9 100644 --- a/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/client/watch/body.go +++ b/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/client/watch/body.go @@ -32,7 +32,6 @@ func (wr *bodyWatcher) Stop() { return default: wr.stop() - close(wr.results) } } @@ -51,7 +50,7 @@ func (wr *bodyWatcher) stream() { go func() { //nolint:errcheck defer wr.res.Body.Close() - + out: for { // Read a line b, err := reader.ReadBytes('\n') @@ -69,9 +68,15 @@ func (wr *bodyWatcher) stream() { if err := json.Unmarshal(b, &event); err != nil { continue } - wr.results <- event + + select { + case <-wr.ctx.Done(): + break out + case wr.results <- event: + } } + close(wr.results) // stop the watcher wr.Stop() }() diff --git a/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/watcher.go b/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/watcher.go index 27e594bbeac..b90180845ac 100644 --- a/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/watcher.go +++ b/vendor/github.com/go-micro/plugins/v4/registry/kubernetes/watcher.go @@ -24,6 +24,7 @@ type k8sWatcher struct { sync.RWMutex pods map[string]*client.Pod + sync.Once } // build a cache of pods when the watcher starts. @@ -164,7 +165,9 @@ func (k *k8sWatcher) Stop() { case <-k.next: return default: - close(k.next) + k.Do(func() { + close(k.next) + }) } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 2d2876e93e8..2102e482de2 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -893,7 +893,7 @@ github.com/go-micro/plugins/v4/registry/consul # github.com/go-micro/plugins/v4/registry/etcd v1.2.0 ## explicit; go 1.17 github.com/go-micro/plugins/v4/registry/etcd -# github.com/go-micro/plugins/v4/registry/kubernetes v1.1.1 +# github.com/go-micro/plugins/v4/registry/kubernetes v1.1.2-0.20230605104008-a179a6b8f8e6 ## explicit; go 1.18 github.com/go-micro/plugins/v4/registry/kubernetes github.com/go-micro/plugins/v4/registry/kubernetes/client