Skip to content

Commit

Permalink
Fix issue with flapping links when ids are the same. Fixes #1645
Browse files Browse the repository at this point in the history
  • Loading branch information
plorenz committed Dec 18, 2023
1 parent a2bfd2a commit 975f5ff
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
6 changes: 5 additions & 1 deletion router/link/link_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -34,6 +35,7 @@ import (
)

type Env interface {
GetRouterId() *identity.TokenId
GetNetworkControllers() env.NetworkControllers
GetXlinkDialers() []xlink.Dialer
GetCloseNotify() <-chan struct{}
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions tests/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion zititest/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions zititest/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 975f5ff

Please sign in to comment.