Skip to content

Commit

Permalink
[Automated] Merged refs/heads/k8s-sync-2024-11-19-1529-99ae3101438c7a…
Browse files Browse the repository at this point in the history
…2e0ec58c6ada69f9baac534901 into target main
  • Loading branch information
github-actions[bot] authored Nov 19, 2024
2 parents d1712ff + 462d78e commit 46d6fdd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vclusterops/cluster_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,11 @@ func (op *opBase) isSkipExecute() bool {
// hasQuorum checks if we have enough working primary nodes to maintain data integrity
// quorumCount = (1/2 * number of primary nodes) + 1
func (op *opBase) hasQuorum(hostCount, primaryNodeCount uint) bool {
quorumCount := (primaryNodeCount + 1) / 2
quorumCount := primaryNodeCount/2 + 1
if hostCount < quorumCount {
op.logger.PrintError("[%s] Quorum check failed: "+
"number of hosts with latest catalog (%d) is not "+
"greater than or equal to 1/2 of number of the primary nodes (%d)\n",
"greater than 1/2 of number of the primary nodes (%d)\n",
op.name, hostCount, primaryNodeCount)
return false
}
Expand Down
8 changes: 7 additions & 1 deletion vclusterops/cluster_op_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestHasQuorum(t *testing.T) {

// positive case 1:
hostCount := uint(2)
primaryNodeCount := uint(4)
primaryNodeCount := uint(3)
succeed := op.hasQuorum(hostCount, primaryNodeCount)
assert.Equal(t, succeed, true)

Expand All @@ -53,4 +53,10 @@ func TestHasQuorum(t *testing.T) {
primaryNodeCount = 5
succeed = op.hasQuorum(hostCount, primaryNodeCount)
assert.Equal(t, succeed, false)

// negative case 3:
hostCount = 2
primaryNodeCount = 4
succeed = op.hasQuorum(hostCount, primaryNodeCount)
assert.Equal(t, succeed, false)
}

0 comments on commit 46d6fdd

Please sign in to comment.