Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
sky333999 committed Aug 14, 2024
1 parent 9c631d4 commit bab8231
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ func TestGetNodeStatusCapacityGPUs(t *testing.T) {
assert.True(t, valid)
assert.Equal(t, uint64(20), nodeStatusCapacityGPUs)

nodeInfo = newNodeInfo("testNodeNonExistent", &mockNodeInfoProvider{}, zap.NewNop())
nodeStatusCapacityGPUs, valid = nodeInfo.getNodeStatusAllocatablePods()
assert.False(t, valid)
nodeInfo = newNodeInfo("testNode2", &mockNodeInfoProvider{}, zap.NewNop())
nodeStatusCapacityGPUs, valid = nodeInfo.getNodeStatusCapacityGPUs()
assert.True(t, valid)
assert.Equal(t, uint64(0), nodeStatusCapacityGPUs)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,11 +414,9 @@ func (p *PodStore) decorateGPU(metric CIMetric, pod *corev1.Pod) {
if p.includeEnhancedMetrics && p.enableAcceleratedComputeMetrics && metric.GetTag(ci.MetricType) == ci.TypePod &&
pod.Status.Phase != corev1.PodSucceeded && pod.Status.Phase != corev1.PodFailed {

if podGpuRequest, ok := getResourceSettingForPod(pod, 0, gpuKey, getRequestForContainer); ok {
metric.AddField(ci.MetricName(ci.TypePod, ci.GpuRequest), podGpuRequest)
}

if podGpuLimit, ok := getResourceSettingForPod(pod, 0, gpuKey, getLimitForContainer); ok {
podGpuRequest, _ := getResourceSettingForPod(pod, 0, gpuKey, getRequestForContainer)
metric.AddField(ci.MetricName(ci.TypePod, ci.GpuRequest), podGpuRequest)
metric.AddField(ci.MetricName(ci.TypePod, ci.GpuLimit), podGpuLimit)
var podGpuUsageTotal uint64
if pod.Status.Phase == corev1.PodRunning { // Set the GPU limit as the usage_total for running pods only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ func (m *mockNodeInfoProvider) NodeToCapacityMap() map[string]v1.ResourceList {
"nvidia.com/gpu": *resource.NewQuantity(20, resource.DecimalExponent),
},
"testNode2": {
"pods": *resource.NewQuantity(10, resource.DecimalSI),
"nvidia.com/gpu": *resource.NewQuantity(30, resource.DecimalExponent),
"pods": *resource.NewQuantity(10, resource.DecimalSI),
},
}
}
Expand All @@ -83,8 +82,7 @@ func (m *mockNodeInfoProvider) NodeToAllocatableMap() map[string]v1.ResourceList
"nvidia.com/gpu": *resource.NewQuantity(20, resource.DecimalExponent),
},
"testNode2": {
"pods": *resource.NewQuantity(20, resource.DecimalSI),
"nvidia.com/gpu": *resource.NewQuantity(30, resource.DecimalExponent),
"pods": *resource.NewQuantity(20, resource.DecimalSI),
},
}
}
Expand Down

0 comments on commit bab8231

Please sign in to comment.