Skip to content

Commit

Permalink
hs-test: fix readCpus
Browse files Browse the repository at this point in the history
return error otherwise hst might panic

Type: test

Change-Id: Ib3ec8a2113af4594f2c2fc54ae72e358bfadaef2
Signed-off-by: Matus Fabian <[email protected]>
  • Loading branch information
matfabia authored and dwallacelf committed Dec 18, 2024
1 parent 0cf4eef commit 91b626a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions extras/hs-test/infra/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ func (c *CpuAllocatorT) readCpus() error {

// make c.cpus divisible by maxContainerCount * nCpus, so we don't have to check which numa will be used
// and we can use offsets
count_to_remove := len(tmpCpus) % (c.maxContainerCount * *NConfiguredCpus)
c.cpus = append(c.cpus, tmpCpus[:len(tmpCpus)-count_to_remove]...)
countToRemove := len(tmpCpus) % (c.maxContainerCount * *NConfiguredCpus)
if countToRemove >= len(tmpCpus) {
return fmt.Errorf("requested too much CPUs per container (%d) should be no more than %d", *NConfiguredCpus, len(tmpCpus)/c.maxContainerCount)
}
c.cpus = append(c.cpus, tmpCpus[:len(tmpCpus)-countToRemove]...)
tmpCpus = tmpCpus[:0]
}
} else {
Expand Down

0 comments on commit 91b626a

Please sign in to comment.