Skip to content

Commit

Permalink
provide some small code optimization
Browse files Browse the repository at this point in the history
Signed-off-by: Thor-wl <[email protected]>
  • Loading branch information
Thor-wl committed Jul 7, 2022
1 parent 77f8ba4 commit 88aa103
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions pkg/plugin/nvidia/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ import (

func IsGPURequiredContainer(c *v1.Container) bool {
vmemory := GetGPUResourceOfContainer(c)
if vmemory == 0 {
return false
}

return true
return vmemory > 0
}

func GetGPUResourceOfContainer(container *v1.Container) uint {
Expand All @@ -62,8 +58,7 @@ func GenerateVirtualDeviceID(id uint, fakeCounter uint) string {
}

func SetGPUMemory(raw uint) {
v := raw
gpuMemory = v
gpuMemory = raw
log.Infof("set gpu memory: %d", gpuMemory)
}

Expand Down Expand Up @@ -118,14 +113,7 @@ func (s podSlice) Swap(i, j int) {
}

func IsGPURequiredPod(pod *v1.Pod) bool {

vmemory := GetGPUResourceOfPod(pod, VolcanoGPUResource)

if vmemory <= 0 {
return false
}

return true
return GetGPUResourceOfPod(pod, VolcanoGPUResource) > 0
}

func IsGPUAssignedPod(pod *v1.Pod) bool {
Expand Down Expand Up @@ -158,10 +146,7 @@ func IsShouldDeletePod(pod *v1.Pod) bool {
return true
}
}
if pod.Status.Reason == "UnexpectedAdmissionError" {
return true
}
return false
return pod.Status.Reason == "UnexpectedAdmissionError"
}

func GetGPUResourceOfPod(pod *v1.Pod, resourceName v1.ResourceName) uint {
Expand Down

0 comments on commit 88aa103

Please sign in to comment.