Skip to content

Commit

Permalink
fix(sysadvisor): check pod number for dedicated region
Browse files Browse the repository at this point in the history
Signed-off-by: linzhecheng <linzhecheng@bytedance.com>
  • Loading branch information
cheney-lin authored and waynepeking348 committed Sep 21, 2023
1 parent 5813398 commit c440dce
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ func (pa *ProvisionAssemblerCommon) AssembleProvision() (types.InternalCPUCalcul
reservedForReclaim := pa.getNumasReservedForReclaim(r.GetBindingNumas())

podSet := r.GetPods()
if podSet.Len() != 1 {
return types.InternalCPUCalculationResult{}, false, fmt.Errorf("more than one pod are assgined to numa exclusive region")
if podSet.Pods() != 1 {
return types.InternalCPUCalculationResult{}, false, fmt.Errorf("more than one pod are assgined to numa exclusive region: %v", podSet)
}
podUID, _, _ := podSet.PopAny()

Expand Down
10 changes: 6 additions & 4 deletions pkg/agent/sysadvisor/types/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ func (ps PodSet) PopAny() (string, string, bool) {
return zeroValue, zeroValue, false
}

func (ps PodSet) Len() int {
length := 0
func (ps PodSet) Pods() int {
count := 0
for _, containerNames := range ps {
length += containerNames.Len()
if containerNames.Len() > 0 {
count++
}
}
return length
return count
}

func (r *InternalCPUCalculationResult) GetPoolEntry(poolName string, numaID int) (int, bool) {
Expand Down

0 comments on commit c440dce

Please sign in to comment.