diff --git a/server/modules/sostatus/sostatus.go b/server/modules/sostatus/sostatus.go index b0f33862b..d8135a3e0 100644 --- a/server/modules/sostatus/sostatus.go +++ b/server/modules/sostatus/sostatus.go @@ -95,6 +95,7 @@ func (status *SoStatus) Refresh(ctx context.Context) { func (status *SoStatus) refreshGrid(ctx context.Context) { unhealthyNodes := 0 + nonCriticalNodes := 0 nodes := status.server.Datastore.GetNodes(ctx) for _, node := range nodes { @@ -129,12 +130,16 @@ func (status *SoStatus) refreshGrid(ctx context.Context) { if node.Status != model.NodeStatusOk && node.Status != model.NodeStatusRestart && !node.NonCriticalNode { unhealthyNodes++ } + + if node.NonCriticalNode { + nonCriticalNodes++ + } } status.currentStatus.Grid.TotalNodeCount = len(nodes) status.currentStatus.Grid.UnhealthyNodeCount = unhealthyNodes status.currentStatus.Grid.Eps = status.server.Metrics.GetGridEps(ctx) - licensing.ValidateNodeCount(len(nodes)) + licensing.ValidateNodeCount(status.currentStatus.Grid.TotalNodeCount - nonCriticalNodes) } func (status *SoStatus) refreshDetections(ctx context.Context) { diff --git a/server/modules/sostatus/sostatus_test.go b/server/modules/sostatus/sostatus_test.go index 081668004..c8fbd1725 100644 --- a/server/modules/sostatus/sostatus_test.go +++ b/server/modules/sostatus/sostatus_test.go @@ -40,7 +40,7 @@ func TestRefreshGrid_LicensedNodes(tester *testing.T) { status.refreshGrid(context.Background()) assert.Equal(tester, licensing.LICENSE_STATUS_ACTIVE, licensing.GetStatus()) - // FakeServer has 2 fake nodes, since 2 > 1 the license will be exceeded + // FakeServer has 2 fake critical nodes, since 2 > 1 the license will be exceeded licensing.Test("foo", 0, 1, "", "") status.refreshGrid(context.Background()) assert.Equal(tester, licensing.LICENSE_STATUS_EXCEEDED, licensing.GetStatus()) @@ -50,7 +50,7 @@ func TestRefreshGrid(tester *testing.T) { status, _ := NewTestStatus() status.refreshGrid(context.Background()) - assert.Equal(tester, 1, status.currentStatus.Grid.UnhealthyNodeCount) - assert.Equal(tester, 2, status.currentStatus.Grid.TotalNodeCount) + assert.Equal(tester, 2, status.currentStatus.Grid.UnhealthyNodeCount) + assert.Equal(tester, 3, status.currentStatus.Grid.TotalNodeCount) assert.Equal(tester, 12, status.currentStatus.Grid.Eps) } diff --git a/server/server_fake.go b/server/server_fake.go index d0d957334..dacc35f70 100644 --- a/server/server_fake.go +++ b/server/server_fake.go @@ -67,6 +67,7 @@ func NewFakeDatastore() *FakeDatastore { nodes := make([]*model.Node, 0) nodes = append(nodes, &model.Node{}) nodes = append(nodes, &model.Node{Status: model.NodeStatusRestart}) + nodes = append(nodes, &model.Node{NonCriticalNode: false}) jobs := make([]*model.Job, 0) jobs = append(jobs, &model.Job{})