Skip to content

Commit

Permalink
Merge pull request #2056 from openziti/fix-cluster-op-panic
Browse files Browse the repository at this point in the history
Don't panic if agent cluster ops are run when not in cluster mode. Fixes #2055
  • Loading branch information
plorenz authored May 22, 2024
2 parents 78c0ab4 + f8682c6 commit 1d71b9e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ ziti edge create service test --terminator-strategy sticky
* github.com/openziti/storage: [v0.2.37 -> v0.2.41](https://github.com/openziti/storage/compare/v0.2.37...v0.2.41)
* github.com/openziti/transport/v2: [v2.0.131 -> v2.0.133](https://github.com/openziti/transport/compare/v2.0.131...v2.0.133)
* github.com/openziti/ziti: [v1.1.2 -> v1.1.3](https://github.com/openziti/ziti/compare/v1.1.2...v1.1.3)
* [Issue #2055](https://github.com/openziti/ziti/issues/2055) - Controller panics on 'ziti agent cluster list'
* [Issue #2019](https://github.com/openziti/ziti/issues/2019) - Support mechanism for sticky dials

# Release 1.1.2
Expand Down
25 changes: 25 additions & 0 deletions controller/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ func (self *Controller) agentOpSnapshotDb(m *channel.Message, ch channel.Channel
}

func (self *Controller) agentOpRaftList(m *channel.Message, ch channel.Channel) {
if self.raftController == nil {
handler_common.SendOpResult(m, ch, "raft.list", "controller not running in clustered mode", false)
return
}

members, err := self.raftController.ListMembers()
if err != nil {
handler_common.SendOpResult(m, ch, "raft.list", err.Error(), false)
Expand All @@ -100,6 +105,11 @@ func (self *Controller) agentOpRaftList(m *channel.Message, ch channel.Channel)
}

func (self *Controller) agentOpRaftAddPeer(m *channel.Message, ch channel.Channel) {
if self.raftController == nil {
handler_common.SendOpResult(m, ch, "raft.list", "controller not running in clustered mode", false)
return
}

addr, found := m.GetStringHeader(AgentAddrHeader)
if !found {
handler_common.SendOpResult(m, ch, "raft.join", "address not supplied", false)
Expand Down Expand Up @@ -137,6 +147,11 @@ func (self *Controller) agentOpRaftAddPeer(m *channel.Message, ch channel.Channe
}

func (self *Controller) agentOpRaftRemovePeer(m *channel.Message, ch channel.Channel) {
if self.raftController == nil {
handler_common.SendOpResult(m, ch, "raft.list", "controller not running in clustered mode", false)
return
}

id, found := m.GetStringHeader(AgentIdHeader)
if !found {
handler_common.SendOpResult(m, ch, "cluster.remove-peer", "id not supplied", false)
Expand All @@ -155,6 +170,11 @@ func (self *Controller) agentOpRaftRemovePeer(m *channel.Message, ch channel.Cha
}

func (self *Controller) agentOpRaftTransferLeadership(m *channel.Message, ch channel.Channel) {
if self.raftController == nil {
handler_common.SendOpResult(m, ch, "raft.list", "controller not running in clustered mode", false)
return
}

id, _ := m.GetStringHeader(AgentIdHeader)
req := &cmd_pb.TransferLeadershipRequest{
Id: id,
Expand All @@ -168,6 +188,11 @@ func (self *Controller) agentOpRaftTransferLeadership(m *channel.Message, ch cha
}

func (self *Controller) agentOpInitFromDb(m *channel.Message, ch channel.Channel) {
if self.raftController == nil {
handler_common.SendOpResult(m, ch, "raft.list", "controller not running in clustered mode", false)
return
}

sourceDbPath := string(m.Body)
if len(sourceDbPath) == 0 {
handler_common.SendOpResult(m, ch, "raft.initFromDb", "source db not supplied", false)
Expand Down

0 comments on commit 1d71b9e

Please sign in to comment.