Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unfreeze active nodes metrics once a consenter is evicted #3536

Merged
merged 1 commit into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions orderer/consensus/etcdraft/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,9 @@ func (c *Chain) halt() {
// StatusReport.
c.consensusRelation = types.ConsensusRelationConfigTracker
}

// active nodes metric shouldn't be frozen once a channel is stopped.
c.Metrics.ActiveNodes.Set(float64(0))
}

func (c *Chain) isRunning() error {
Expand Down
8 changes: 8 additions & 0 deletions orderer/consensus/etcdraft/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,7 @@ var _ = Describe("Chain", func() {
c1.clock.Increment(interval)
return c2.fakeFields.fakeActiveNodes.SetCallCount()
}, LongEventualTimeout).Should(Equal(2))
Expect(c1.fakeFields.fakeActiveNodes.SetArgsForCall(1)).To(Equal(float64(2)))
Expect(c2.fakeFields.fakeActiveNodes.SetArgsForCall(1)).To(Equal(float64(2)))

By("Configuring cluster to remove node")
Expand Down Expand Up @@ -1459,6 +1460,8 @@ var _ = Describe("Chain", func() {
c2.cutter.CutNext = true
Expect(c2.Order(env, 0)).To(Succeed())
Eventually(c2.support.WriteBlockCallCount, LongEventualTimeout).Should(Equal(1))
Expect(c1.fakeFields.fakeActiveNodes.SetArgsForCall(2)).To(Equal(float64(0))) // was halted
Expect(c2.fakeFields.fakeActiveNodes.SetArgsForCall(1)).To(Equal(float64(2)))
})

It("remove leader by reconfiguring cluster, but Halt before eviction", func() {
Expand All @@ -1469,6 +1472,7 @@ var _ = Describe("Chain", func() {
c1.clock.Increment(interval)
return c2.fakeFields.fakeActiveNodes.SetCallCount()
}, LongEventualTimeout).Should(Equal(2))
Expect(c1.fakeFields.fakeActiveNodes.SetArgsForCall(1)).To(Equal(float64(2)))
Expect(c2.fakeFields.fakeActiveNodes.SetArgsForCall(1)).To(Equal(float64(2)))

By("Configuring cluster to remove node")
Expand Down Expand Up @@ -1499,6 +1503,10 @@ var _ = Describe("Chain", func() {
).Should(Equal(orderer_types.StatusInactive))
cRel, _ := c1.StatusReport()
Expect(cRel).To(Equal(orderer_types.ConsensusRelationConsenter))

// active nodes metric hasn't changed because c.halt() wasn't called
Expect(c1.fakeFields.fakeActiveNodes.SetArgsForCall(1)).To(Equal(float64(2)))
Expect(c2.fakeFields.fakeActiveNodes.SetArgsForCall(1)).To(Equal(float64(2)))
})

It("can remove leader by reconfiguring cluster even if leadership transfer fails", func() {
Expand Down