mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 20:53:33 +00:00
Merge pull request #57369 from vikaschoudhary16/revert-to-limits
Automatic merge from submit-queue (batch tested with PRs 57591, 57369). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Revert back #57278 **What this PR does / why we need it**: This PR reverts back to behavior of scanning Limits. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Related # #57276 #57170 **Special notes for your reviewer**: **Release note**: ```release-note None ``` /sig node /cc @vishh @ConnorDoyle @jiayingz
This commit is contained in:
commit
7dd82519da
@ -550,10 +550,11 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
|
||||
podUID := string(pod.UID)
|
||||
contName := container.Name
|
||||
allocatedDevicesUpdated := false
|
||||
// NOTE: Skipping the Resources.Limits is safe here because:
|
||||
// 1. If container Spec mentions Limits only, implicitly Requests, equal to Limits, will get added to the Spec.
|
||||
// 2. If container Spec mentions Limits, which are greater than or less than Requests, will fail at validation.
|
||||
for k, v := range container.Resources.Requests {
|
||||
// Extended resources are not allowed to be overcommitted.
|
||||
// Since device plugin advertises extended resources,
|
||||
// therefore Requests must be equal to Limits and iterating
|
||||
// over the Limits should be sufficient.
|
||||
for k, v := range container.Resources.Limits {
|
||||
resource := string(k)
|
||||
needed := int(v.Value())
|
||||
glog.V(3).Infof("needs %d %s", needed, resource)
|
||||
|
@ -366,7 +366,7 @@ func (m *MockEndpoint) allocate(devs []string) (*pluginapi.AllocateResponse, err
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func makePod(requests v1.ResourceList) *v1.Pod {
|
||||
func makePod(limits v1.ResourceList) *v1.Pod {
|
||||
return &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
UID: uuid.NewUUID(),
|
||||
@ -375,7 +375,7 @@ func makePod(requests v1.ResourceList) *v1.Pod {
|
||||
Containers: []v1.Container{
|
||||
{
|
||||
Resources: v1.ResourceRequirements{
|
||||
Requests: requests,
|
||||
Limits: limits,
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -616,7 +616,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
||||
{
|
||||
Name: string(uuid.NewUUID()),
|
||||
Resources: v1.ResourceRequirements{
|
||||
Requests: v1.ResourceList{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceName(res1.resourceName): res2.resourceQuantity,
|
||||
},
|
||||
},
|
||||
@ -624,7 +624,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
||||
{
|
||||
Name: string(uuid.NewUUID()),
|
||||
Resources: v1.ResourceRequirements{
|
||||
Requests: v1.ResourceList{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceName(res1.resourceName): res1.resourceQuantity,
|
||||
},
|
||||
},
|
||||
@ -634,7 +634,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
||||
{
|
||||
Name: string(uuid.NewUUID()),
|
||||
Resources: v1.ResourceRequirements{
|
||||
Requests: v1.ResourceList{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceName(res1.resourceName): res2.resourceQuantity,
|
||||
v1.ResourceName(res2.resourceName): res2.resourceQuantity,
|
||||
},
|
||||
@ -643,7 +643,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
||||
{
|
||||
Name: string(uuid.NewUUID()),
|
||||
Resources: v1.ResourceRequirements{
|
||||
Requests: v1.ResourceList{
|
||||
Limits: v1.ResourceList{
|
||||
v1.ResourceName(res1.resourceName): res2.resourceQuantity,
|
||||
v1.ResourceName(res2.resourceName): res2.resourceQuantity,
|
||||
},
|
||||
@ -664,6 +664,10 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
||||
initCont2Devices := testManager.podDevices.containerDevices(podUID, initCont2, res1.resourceName)
|
||||
normalCont1Devices := testManager.podDevices.containerDevices(podUID, normalCont1, res1.resourceName)
|
||||
normalCont2Devices := testManager.podDevices.containerDevices(podUID, normalCont2, res1.resourceName)
|
||||
as.Equal(1, initCont1Devices.Len())
|
||||
as.Equal(2, initCont2Devices.Len())
|
||||
as.Equal(1, normalCont1Devices.Len())
|
||||
as.Equal(1, normalCont2Devices.Len())
|
||||
as.True(initCont2Devices.IsSuperset(initCont1Devices))
|
||||
as.True(initCont2Devices.IsSuperset(normalCont1Devices))
|
||||
as.True(initCont2Devices.IsSuperset(normalCont2Devices))
|
||||
|
Loading…
Reference in New Issue
Block a user