mirror of https://github.com/k3s-io/k3s
Look for requested resources in the Requests
parent
6b03a43b76
commit
bf1fb46347
|
@ -550,7 +550,10 @@ func (m *ManagerImpl) allocateContainerResources(pod *v1.Pod, container *v1.Cont
|
|||
podUID := string(pod.UID)
|
||||
contName := container.Name
|
||||
allocatedDevicesUpdated := false
|
||||
for k, v := range container.Resources.Limits {
|
||||
// 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 {
|
||||
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(limits v1.ResourceList) *v1.Pod {
|
||||
func makePod(requests v1.ResourceList) *v1.Pod {
|
||||
return &v1.Pod{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
UID: uuid.NewUUID(),
|
||||
|
@ -375,7 +375,7 @@ func makePod(limits v1.ResourceList) *v1.Pod {
|
|||
Containers: []v1.Container{
|
||||
{
|
||||
Resources: v1.ResourceRequirements{
|
||||
Limits: limits,
|
||||
Requests: requests,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -616,7 +616,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
|||
{
|
||||
Name: string(uuid.NewUUID()),
|
||||
Resources: v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceName(res1.resourceName): res2.resourceQuantity,
|
||||
},
|
||||
},
|
||||
|
@ -624,7 +624,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
|||
{
|
||||
Name: string(uuid.NewUUID()),
|
||||
Resources: v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceName(res1.resourceName): res1.resourceQuantity,
|
||||
},
|
||||
},
|
||||
|
@ -634,7 +634,7 @@ func TestInitContainerDeviceAllocation(t *testing.T) {
|
|||
{
|
||||
Name: string(uuid.NewUUID()),
|
||||
Resources: v1.ResourceRequirements{
|
||||
Limits: v1.ResourceList{
|
||||
Requests: 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{
|
||||
Limits: v1.ResourceList{
|
||||
Requests: v1.ResourceList{
|
||||
v1.ResourceName(res1.resourceName): res2.resourceQuantity,
|
||||
v1.ResourceName(res2.resourceName): res2.resourceQuantity,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue