Skip to content

Commit

Permalink
Remove missing extended resources from init containers
Browse files Browse the repository at this point in the history
Signed-off-by: Panos Woo <panoswoo@outlook.com>
  • Loading branch information
panoswoo committed Apr 11, 2024
1 parent 9791f0d commit 475c670
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/kubelet/lifecycle/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ func removeMissingExtendedResources(pod *v1.Pod, nodeInfo *schedulerframework.No
podCopy.Spec.Containers[i].Resources.Requests[rName] = rQuant
}
}
for i, c := range pod.Spec.InitContainers {
podCopy.Spec.InitContainers[i].Resources.Requests = make(v1.ResourceList)
for rName, rQuant := range c.Resources.Requests {
if v1helper.IsExtendedResourceName(rName) {
if _, found := nodeInfo.Allocatable.ScalarResources[rName]; !found {
continue
}
}
podCopy.Spec.InitContainers[i].Resources.Requests[rName] = rQuant
}
}
return podCopy
}

Expand Down
8 changes: 8 additions & 0 deletions pkg/kubelet/lifecycle/predicate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ func makeTestPod(requests, limits v1.ResourceList) *v1.Pod {
},
},
},
InitContainers: []v1.Container{
{
Resources: v1.ResourceRequirements{
Requests: requests,
Limits: limits,
},
},
},
},
}
}
Expand Down

0 comments on commit 475c670

Please sign in to comment.