diff options
author | 2024-12-18 14:20:31 +0100 | |
---|---|---|
committer | 2024-12-18 16:09:57 +0000 | |
commit | 91b626a4071bef211253a7f239e0e36605e24ce8 (patch) | |
tree | 115cb7134a299bd36177883296371cfa5373e718 /extras/hs-test | |
parent | 0cf4eef73a4c1bd2831a4618af50939a2aab01c6 (diff) |
hs-test: fix readCpus
return error otherwise hst might panic
Type: test
Change-Id: Ib3ec8a2113af4594f2c2fc54ae72e358bfadaef2
Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'extras/hs-test')
-rw-r--r-- | extras/hs-test/infra/cpu.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/extras/hs-test/infra/cpu.go b/extras/hs-test/infra/cpu.go index 7a29eb4a9c3..e871c60af80 100644 --- a/extras/hs-test/infra/cpu.go +++ b/extras/hs-test/infra/cpu.go @@ -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 { |