Skip to content

Commit

Permalink
Merge pull request #2695 from openziti/rdm-always-in-ha
Browse files Browse the repository at this point in the history
Always use RDM when there are multiple controllers. Fixes #2694
  • Loading branch information
plorenz authored Jan 27, 2025
2 parents fa3fa10 + b96ae50 commit 2a62cc5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Release 1.3.3

# What's New

* Bug Fixes

## Component Updates and Bug Fixes

* github.com/openziti/ziti: [v1.3.2 -> v1.3.3](https://github.com/openziti/ziti/compare/v1.3.2...v1.3.3)
* [Issue #2694](https://github.com/openziti/ziti/issues/2694) - Router should use router data model if it has more than one controller configured, regardless of controller configuration


# Release 1.3.2

# What's New
Expand Down
8 changes: 8 additions & 0 deletions router/env/ctrls.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
cmap "github.com/orcaman/concurrent-map/v2"
"github.com/pkg/errors"
"sync"
"sync/atomic"
"time"

"github.com/openziti/channel/v3"
Expand Down Expand Up @@ -74,6 +75,7 @@ type NetworkControllers interface {
Inspect() *inspect.ControllerInspectDetails
AddChangeListener(listener CtrlEventListener)
NotifyOfReconnect(ctrlId string)
GetExpectedCtrlCount() uint32
}

type CtrlDialer func(address transport.Address, bindHandler channel.BindHandler) error
Expand All @@ -96,16 +98,22 @@ type networkControllers struct {
ctrls concurrenz.CopyOnWriteMap[string, NetworkController]
leaderId concurrenz.AtomicValue[string]
ctrlChangeListeners concurrenz.CopyOnWriteSlice[CtrlEventListener]
expectedCtrlCount atomic.Uint32
}

func (self *networkControllers) AddChangeListener(listener CtrlEventListener) {
self.ctrlChangeListeners.Append(listener)
}

func (self *networkControllers) GetExpectedCtrlCount() uint32 {
return self.expectedCtrlCount.Load()
}

func (self *networkControllers) UpdateControllerEndpoints(addresses []string) bool {
self.lock.Lock()
defer self.lock.Unlock()

self.expectedCtrlCount.Store(uint32(len(addresses)))
changed := false

log := pfxlog.Logger()
Expand Down
6 changes: 5 additions & 1 deletion router/handler_ctrl/bind.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,11 @@ func (self *bindHandler) BindChannel(binding channel.Binding) error {
}

enableRouterDataModel := capabilities.IsCapable(binding.GetChannel(), capabilities.RouterDataModel)
self.env.GetRouterDataModelEnabledConfig().Store(enableRouterDataModel)
if self.env.GetNetworkControllers().GetExpectedCtrlCount() < 2 {
self.env.GetRouterDataModelEnabledConfig().Store(enableRouterDataModel)
} else {
self.env.GetRouterDataModelEnabledConfig().Store(true)
}

return nil
}

0 comments on commit 2a62cc5

Please sign in to comment.