Skip to content

Commit

Permalink
exempt desktops from license node count
Browse files Browse the repository at this point in the history
  • Loading branch information
jertel committed Aug 14, 2024
1 parent 5f320c3 commit bdebe9a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion server/modules/sostatus/sostatus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions server/modules/sostatus/sostatus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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)
}
1 change: 1 addition & 0 deletions server/server_fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{})
Expand Down

0 comments on commit bdebe9a

Please sign in to comment.