From 975f5ff18dcdbdfe49bf5dbc2e4fcf3ee99b61fa Mon Sep 17 00:00:00 2001 From: Paul Lorenz Date: Fri, 15 Dec 2023 15:04:27 -0500 Subject: [PATCH] Fix issue with flapping links when ids are the same. Fixes #1645 --- CHANGELOG.md | 3 +++ go.mod | 2 +- go.sum | 4 ++-- router/link/link_registry.go | 6 +++++- tests/link_test.go | 6 ++++++ zititest/go.mod | 2 +- zititest/go.sum | 4 ++-- 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1efa922041..0a749e269c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,8 +11,11 @@ ## Component Updates and Bug Fixes * github.com/openziti/metrics: [v1.2.40 -> v1.2.41](https://github.com/openziti/metrics/compare/v1.2.40...v1.2.41) +* github.com/openziti/sdk-golang: [v0.21.2 -> v0.21.4](https://github.com/openziti/sdk-golang/compare/v0.21.2...v0.21.4) * github.com/openziti/storage: [v0.2.26 -> v0.2.27](https://github.com/openziti/storage/compare/v0.2.26...v0.2.27) * github.com/openziti/ziti: [v0.31.3 -> v0.31.4](https://github.com/openziti/ziti/compare/v0.31.3...v0.31.4) + * [Issue #1645](https://github.com/openziti/ziti/issues/1645) - Once routers share a link id, we can't use the link id to decide which duplicate link to discard + * [Issue #1642](https://github.com/openziti/ziti/issues/1642) - Revert posture check optimization * [Issue #1586](https://github.com/openziti/ziti/issues/1586) - If ack is received before payload is processed by link send buffer, a stall can result # Release 0.31.3 diff --git a/go.mod b/go.mod index 0bc966a2a6..316d501681 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/openziti/jwks v1.0.3 github.com/openziti/metrics v1.2.41 github.com/openziti/runzmd v1.0.36 - github.com/openziti/sdk-golang v0.21.2 + github.com/openziti/sdk-golang v0.22.0 github.com/openziti/secretstream v0.1.14 github.com/openziti/storage v0.2.27 github.com/openziti/transport/v2 v2.0.119 diff --git a/go.sum b/go.sum index 3be2d3ba3c..3f40661eb3 100644 --- a/go.sum +++ b/go.sum @@ -596,8 +596,8 @@ github.com/openziti/metrics v1.2.41 h1:JShcFb6qJPA2cMiWQLtcSXiJjsrhEWpH+aVcjT/Mc github.com/openziti/metrics v1.2.41/go.mod h1:L9h0NrliMA3+p7+ascKgvx28qoKHymN9l+CMA+Q+sZc= github.com/openziti/runzmd v1.0.36 h1:HOqTZFzTTFu52qmCAQfFvKDmCSl8ZqP1PQQ0UnJIA4E= github.com/openziti/runzmd v1.0.36/go.mod h1:jYqummjskmFh63htJFF2SrUuvxNQifqd5REUhYVaY/A= -github.com/openziti/sdk-golang v0.21.2 h1:P66cslOAmQX37VFan+df+MoD2PqaFjHWDNMpuhhXHSo= -github.com/openziti/sdk-golang v0.21.2/go.mod h1:mepEUD39DsBm/v1WVLedYRoYCFdet5mmJ5Sxqm/zkFI= +github.com/openziti/sdk-golang v0.22.0 h1:kOXziZTNvMyJc0DIPoQ9izAukkJTL8nqdrlwWfU/Ul0= +github.com/openziti/sdk-golang v0.22.0/go.mod h1:QdoqZHmiajDHywYCh25SGMMA3NipCvO5Iykf8fHi+sI= github.com/openziti/secretstream v0.1.14 h1:Ta+nB5Prcct+L5LIKUA1nE56QhWS6lMPQYTlpxUltU0= github.com/openziti/secretstream v0.1.14/go.mod h1:/hhuLfu+GIv0+cnapfsu/VOnXEvmTt3GKtCu+lQ0RIw= github.com/openziti/storage v0.2.27 h1:WdFD0KxXZxSoWOaojdi5r1LO0BTvn4x/7wwdwhRPssc= diff --git a/router/link/link_registry.go b/router/link/link_registry.go index 3955c77040..fe4d1ecc52 100644 --- a/router/link/link_registry.go +++ b/router/link/link_registry.go @@ -23,6 +23,7 @@ import ( "github.com/openziti/channel/v2" "github.com/openziti/channel/v2/protobufs" "github.com/openziti/foundation/v2/goroutines" + "github.com/openziti/identity" "github.com/openziti/ziti/common/inspect" "github.com/openziti/ziti/common/pb/ctrl_pb" "github.com/openziti/ziti/router/env" @@ -34,6 +35,7 @@ import ( ) type Env interface { + GetRouterId() *identity.TokenId GetNetworkControllers() env.NetworkControllers GetXlinkDialers() []xlink.Dialer GetCloseNotify() <-chan struct{} @@ -118,7 +120,9 @@ func (self *linkRegistryImpl) applyLink(link xlink.Xlink) (xlink.Xlink, bool) { } if existing := self.linkMap[link.Key()]; existing != nil { log = log.WithField("currentLinkId", existing.Id()) - if existing.Id() < link.Id() { + // once we have an established link, we'll store the same id on both sides. Once that happens we can't use + // the link id to decide which duplicate to throw away, so we'll use the router ids instead + if existing.Id() < link.Id() || (existing.Id() == link.Id() && self.env.GetRouterId().Token < link.DestinationId()) { // give the other side a chance to close the link first and report it as a duplicate time.AfterFunc(30*time.Second, func() { if err := link.Close(); err != nil { diff --git a/tests/link_test.go b/tests/link_test.go index 2c5c2aa546..7565e76a41 100644 --- a/tests/link_test.go +++ b/tests/link_test.go @@ -53,6 +53,12 @@ type testRegistryEnv struct { closeNotify chan struct{} } +func (self *testRegistryEnv) GetRouterId() *id.TokenId { + return &id.TokenId{ + Token: "test-router", + } +} + func (self *testRegistryEnv) GetNetworkControllers() env.NetworkControllers { return self.ctrls } diff --git a/zititest/go.mod b/zititest/go.mod index 64eac5553f..153d9a48eb 100644 --- a/zititest/go.mod +++ b/zititest/go.mod @@ -15,7 +15,7 @@ require ( github.com/openziti/fablab v0.5.32 github.com/openziti/foundation/v2 v2.0.35 github.com/openziti/identity v1.0.68 - github.com/openziti/sdk-golang v0.21.2 + github.com/openziti/sdk-golang v0.22.0 github.com/openziti/storage v0.2.27 github.com/openziti/transport/v2 v2.0.119 github.com/openziti/ziti v0.28.3 diff --git a/zititest/go.sum b/zititest/go.sum index db56264849..a6eec74b1c 100644 --- a/zititest/go.sum +++ b/zititest/go.sum @@ -610,8 +610,8 @@ github.com/openziti/metrics v1.2.41 h1:JShcFb6qJPA2cMiWQLtcSXiJjsrhEWpH+aVcjT/Mc github.com/openziti/metrics v1.2.41/go.mod h1:L9h0NrliMA3+p7+ascKgvx28qoKHymN9l+CMA+Q+sZc= github.com/openziti/runzmd v1.0.36 h1:HOqTZFzTTFu52qmCAQfFvKDmCSl8ZqP1PQQ0UnJIA4E= github.com/openziti/runzmd v1.0.36/go.mod h1:jYqummjskmFh63htJFF2SrUuvxNQifqd5REUhYVaY/A= -github.com/openziti/sdk-golang v0.21.2 h1:P66cslOAmQX37VFan+df+MoD2PqaFjHWDNMpuhhXHSo= -github.com/openziti/sdk-golang v0.21.2/go.mod h1:mepEUD39DsBm/v1WVLedYRoYCFdet5mmJ5Sxqm/zkFI= +github.com/openziti/sdk-golang v0.22.0 h1:kOXziZTNvMyJc0DIPoQ9izAukkJTL8nqdrlwWfU/Ul0= +github.com/openziti/sdk-golang v0.22.0/go.mod h1:QdoqZHmiajDHywYCh25SGMMA3NipCvO5Iykf8fHi+sI= github.com/openziti/secretstream v0.1.14 h1:Ta+nB5Prcct+L5LIKUA1nE56QhWS6lMPQYTlpxUltU0= github.com/openziti/secretstream v0.1.14/go.mod h1:/hhuLfu+GIv0+cnapfsu/VOnXEvmTt3GKtCu+lQ0RIw= github.com/openziti/storage v0.2.27 h1:WdFD0KxXZxSoWOaojdi5r1LO0BTvn4x/7wwdwhRPssc=