Merge pull request #36693 from ConnorDoyle/oir-cleanup

Automatic merge from submit-queue (batch tested with PRs 36693, 40154, 40170, 39033)

Minor hygiene in scheduler.

**What this PR does / why we need it**:

Minor cleanups in scheduler, related to PR #31652.

- Unified lazy opaque resource caching.
- Deleted a commented-out line of code.

**Release note**:
```release-note
N/A
```
This commit is contained in:
Kubernetes Submit Queue
2017-01-20 09:18:49 -08:00
committed by GitHub
2 changed files with 13 additions and 20 deletions

View File

@@ -463,11 +463,7 @@ func GetResourceRequest(pod *v1.Pod) *schedulercache.Resource {
result.NvidiaGPU += rQuantity.Value()
default:
if v1.IsOpaqueIntResourceName(rName) {
// Lazily allocate this map only if required.
if result.OpaqueIntResources == nil {
result.OpaqueIntResources = map[v1.ResourceName]int64{}
}
result.OpaqueIntResources[rName] += rQuantity.Value()
result.AddOpaque(rName, rQuantity.Value())
}
}
}
@@ -490,11 +486,9 @@ func GetResourceRequest(pod *v1.Pod) *schedulercache.Resource {
}
default:
if v1.IsOpaqueIntResourceName(rName) {
// Lazily allocate this map only if required.
if result.OpaqueIntResources == nil {
result.OpaqueIntResources = map[v1.ResourceName]int64{}
}
value := rQuantity.Value()
// Ensure the opaque resource map is initialized in the result.
result.AddOpaque(rName, int64(0))
if value > result.OpaqueIntResources[rName] {
result.OpaqueIntResources[rName] = value
}