Merge pull request #116450 from vinaykul/restart-free-pod-vertical-scaling-api

Rename ContainerStatus.ResourcesAllocated to ContainerStatus.AllocatedResources
This commit is contained in:
Kubernetes Prow Robot 2023-03-12 16:06:40 -07:00 committed by GitHub
commit 3c6e419cc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 909 additions and 910 deletions

View File

@ -153,7 +153,7 @@ name | architectures
- PodSpec.Container.Resources becomes mutable for CPU and memory resource types. - PodSpec.Container.Resources becomes mutable for CPU and memory resource types.
- PodSpec.Container.ResizePolicy (new object) gives users control over how their containers are resized. - PodSpec.Container.ResizePolicy (new object) gives users control over how their containers are resized.
- PodStatus.Resize status describes the state of a requested Pod resize. - PodStatus.Resize status describes the state of a requested Pod resize.
- PodStatus.ResourcesAllocated describes node resources allocated to Pod. - PodStatus.AllocatedResources describes node resources allocated to Pod.
- PodStatus.Resources describes node resources applied to running containers by CRI. - PodStatus.Resources describes node resources applied to running containers by CRI.
- UpdateContainerResources CRI API now supports both Linux and Windows. - UpdateContainerResources CRI API now supports both Linux and Windows.

View File

@ -5042,6 +5042,13 @@
"io.k8s.api.core.v1.ContainerStatus": { "io.k8s.api.core.v1.ContainerStatus": {
"description": "ContainerStatus contains details for the current status of this container.", "description": "ContainerStatus contains details for the current status of this container.",
"properties": { "properties": {
"allocatedResources": {
"additionalProperties": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
},
"description": "AllocatedResources represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.",
"type": "object"
},
"containerID": { "containerID": {
"description": "ContainerID is the ID of the container in the format '<type>://<container_id>'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").", "description": "ContainerID is the ID of the container in the format '<type>://<container_id>'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").",
"type": "string" "type": "string"
@ -5070,13 +5077,6 @@
"$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements", "$ref": "#/definitions/io.k8s.api.core.v1.ResourceRequirements",
"description": "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized." "description": "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized."
}, },
"resourcesAllocated": {
"additionalProperties": {
"$ref": "#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
},
"description": "ResourcesAllocated represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.",
"type": "object"
},
"restartCount": { "restartCount": {
"description": "RestartCount holds the number of times the container has been restarted. Kubelet makes an effort to always increment the value, but there are cases when the state may be lost due to node restarts and then the value may be reset to 0. The value is never negative.", "description": "RestartCount holds the number of times the container has been restarted. Kubelet makes an effort to always increment the value, but there are cases when the state may be lost due to node restarts and then the value may be reset to 0. The value is never negative.",
"format": "int32", "format": "int32",

View File

@ -1437,6 +1437,18 @@
"io.k8s.api.core.v1.ContainerStatus": { "io.k8s.api.core.v1.ContainerStatus": {
"description": "ContainerStatus contains details for the current status of this container.", "description": "ContainerStatus contains details for the current status of this container.",
"properties": { "properties": {
"allocatedResources": {
"additionalProperties": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity"
}
],
"default": {}
},
"description": "AllocatedResources represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.",
"type": "object"
},
"containerID": { "containerID": {
"description": "ContainerID is the ID of the container in the format '<type>://<container_id>'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").", "description": "ContainerID is the ID of the container in the format '<type>://<container_id>'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").",
"type": "string" "type": "string"
@ -1478,18 +1490,6 @@
], ],
"description": "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized." "description": "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized."
}, },
"resourcesAllocated": {
"additionalProperties": {
"allOf": [
{
"$ref": "#/components/schemas/io.k8s.apimachinery.pkg.api.resource.Quantity"
}
],
"default": {}
},
"description": "ResourcesAllocated represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.",
"type": "object"
},
"restartCount": { "restartCount": {
"default": 0, "default": 0,
"description": "RestartCount holds the number of times the container has been restarted. Kubelet makes an effort to always increment the value, but there are cases when the state may be lost due to node restarts and then the value may be reset to 0. The value is never negative.", "description": "RestartCount holds the number of times the container has been restarted. Kubelet makes an effort to always increment the value, but there are cases when the state may be lost due to node restarts and then the value may be reset to 0. The value is never negative.",

View File

@ -553,10 +553,10 @@ func dropDisabledPodStatusFields(podStatus, oldPodStatus *api.PodStatus, podSpec
} }
if !utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) && !inPlacePodVerticalScalingInUse(oldPodSpec) { if !utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) && !inPlacePodVerticalScalingInUse(oldPodSpec) {
// Drop Resize, ResourcesAllocated, and Resources fields // Drop Resize, AllocatedResources, and Resources fields
dropResourcesFields := func(csl []api.ContainerStatus) { dropResourcesFields := func(csl []api.ContainerStatus) {
for i := range csl { for i := range csl {
csl[i].ResourcesAllocated = nil csl[i].AllocatedResources = nil
csl[i].Resources = nil csl[i].Resources = nil
} }
} }
@ -862,7 +862,7 @@ func MarkPodProposedForResize(oldPod, newPod *api.Pod) {
return api.ContainerStatus{}, false return api.ContainerStatus{}, false
} }
if cs, ok := findContainerStatus(newPod.Status.ContainerStatuses, c.Name); ok { if cs, ok := findContainerStatus(newPod.Status.ContainerStatuses, c.Name); ok {
if diff.ObjectDiff(c.Resources.Requests, cs.ResourcesAllocated) != "" { if diff.ObjectDiff(c.Resources.Requests, cs.AllocatedResources) != "" {
newPod.Status.Resize = api.PodResizeStatusProposed newPod.Status.Resize = api.PodResizeStatusProposed
break break
} }

View File

@ -2302,7 +2302,7 @@ func TestDropInPlacePodVerticalScaling(t *testing.T) {
{ {
Name: "c1", Name: "c1",
Image: "image", Image: "image",
ResourcesAllocated: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")}, AllocatedResources: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")},
Resources: &api.ResourceRequirements{ Resources: &api.ResourceRequirements{
Requests: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")}, Requests: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")},
Limits: api.ResourceList{api.ResourceCPU: resource.MustParse("300m")}, Limits: api.ResourceList{api.ResourceCPU: resource.MustParse("300m")},
@ -2573,12 +2573,12 @@ func TestMarkPodProposedForResize(t *testing.T) {
{ {
Name: "c1", Name: "c1",
Image: "image", Image: "image",
ResourcesAllocated: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")}, AllocatedResources: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")},
}, },
{ {
Name: "c2", Name: "c2",
Image: "image", Image: "image",
ResourcesAllocated: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")}, AllocatedResources: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")},
}, },
}, },
}, },
@ -2609,12 +2609,12 @@ func TestMarkPodProposedForResize(t *testing.T) {
{ {
Name: "c1", Name: "c1",
Image: "image", Image: "image",
ResourcesAllocated: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")}, AllocatedResources: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")},
}, },
{ {
Name: "c2", Name: "c2",
Image: "image", Image: "image",
ResourcesAllocated: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")}, AllocatedResources: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")},
}, },
}, },
}, },
@ -2646,12 +2646,12 @@ func TestMarkPodProposedForResize(t *testing.T) {
{ {
Name: "c1", Name: "c1",
Image: "image", Image: "image",
ResourcesAllocated: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")}, AllocatedResources: api.ResourceList{api.ResourceCPU: resource.MustParse("100m")},
}, },
{ {
Name: "c2", Name: "c2",
Image: "image", Image: "image",
ResourcesAllocated: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")}, AllocatedResources: api.ResourceList{api.ResourceCPU: resource.MustParse("200m")},
}, },
}, },
}, },

View File

@ -65,9 +65,9 @@ func PodRequests(pod *v1.Pod, opts PodResourcesOptions) v1.ResourceList {
cs, found := containerStatuses[container.Name] cs, found := containerStatuses[container.Name]
if found { if found {
if pod.Status.Resize == v1.PodResizeStatusInfeasible { if pod.Status.Resize == v1.PodResizeStatusInfeasible {
containerReqs = cs.ResourcesAllocated containerReqs = cs.AllocatedResources
} else { } else {
containerReqs = max(container.Resources.Requests, cs.ResourcesAllocated) containerReqs = max(container.Resources.Requests, cs.AllocatedResources)
} }
} }
} }

View File

@ -737,7 +737,7 @@ func TestPodResourceRequests(t *testing.T) {
containerStatus: []v1.ContainerStatus{ containerStatus: []v1.ContainerStatus{
{ {
Name: "container-1", Name: "container-1",
ResourcesAllocated: v1.ResourceList{ AllocatedResources: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("2"), v1.ResourceCPU: resource.MustParse("2"),
}, },
}, },
@ -762,7 +762,7 @@ func TestPodResourceRequests(t *testing.T) {
containerStatus: []v1.ContainerStatus{ containerStatus: []v1.ContainerStatus{
{ {
Name: "container-1", Name: "container-1",
ResourcesAllocated: v1.ResourceList{ AllocatedResources: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("2"), v1.ResourceCPU: resource.MustParse("2"),
}, },
}, },
@ -788,7 +788,7 @@ func TestPodResourceRequests(t *testing.T) {
containerStatus: []v1.ContainerStatus{ containerStatus: []v1.ContainerStatus{
{ {
Name: "container-1", Name: "container-1",
ResourcesAllocated: v1.ResourceList{ AllocatedResources: v1.ResourceList{
v1.ResourceCPU: resource.MustParse("2"), v1.ResourceCPU: resource.MustParse("2"),
}, },
}, },

View File

@ -2492,12 +2492,12 @@ type ContainerStatus struct {
// same as false. // same as false.
// +optional // +optional
Started *bool Started *bool
// ResourcesAllocated represents the compute resources allocated for this container by the // AllocatedResources represents the compute resources allocated for this container by the
// node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission // node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission
// and after successfully admitting desired pod resize. // and after successfully admitting desired pod resize.
// +featureGate=InPlacePodVerticalScaling // +featureGate=InPlacePodVerticalScaling
// +optional // +optional
ResourcesAllocated ResourceList AllocatedResources ResourceList
// Resources represents the compute resource requests and limits that have been successfully // Resources represents the compute resource requests and limits that have been successfully
// enacted on the running container after it has been started or has been successfully resized. // enacted on the running container after it has been started or has been successfully resized.
// +featureGate=InPlacePodVerticalScaling // +featureGate=InPlacePodVerticalScaling

View File

@ -3225,7 +3225,7 @@ func autoConvert_v1_ContainerStatus_To_core_ContainerStatus(in *v1.ContainerStat
out.ImageID = in.ImageID out.ImageID = in.ImageID
out.ContainerID = in.ContainerID out.ContainerID = in.ContainerID
out.Started = (*bool)(unsafe.Pointer(in.Started)) out.Started = (*bool)(unsafe.Pointer(in.Started))
out.ResourcesAllocated = *(*core.ResourceList)(unsafe.Pointer(&in.ResourcesAllocated)) out.AllocatedResources = *(*core.ResourceList)(unsafe.Pointer(&in.AllocatedResources))
out.Resources = (*core.ResourceRequirements)(unsafe.Pointer(in.Resources)) out.Resources = (*core.ResourceRequirements)(unsafe.Pointer(in.Resources))
return nil return nil
} }
@ -3249,7 +3249,7 @@ func autoConvert_core_ContainerStatus_To_v1_ContainerStatus(in *core.ContainerSt
out.ImageID = in.ImageID out.ImageID = in.ImageID
out.ContainerID = in.ContainerID out.ContainerID = in.ContainerID
out.Started = (*bool)(unsafe.Pointer(in.Started)) out.Started = (*bool)(unsafe.Pointer(in.Started))
out.ResourcesAllocated = *(*v1.ResourceList)(unsafe.Pointer(&in.ResourcesAllocated)) out.AllocatedResources = *(*v1.ResourceList)(unsafe.Pointer(&in.AllocatedResources))
out.Resources = (*v1.ResourceRequirements)(unsafe.Pointer(in.Resources)) out.Resources = (*v1.ResourceRequirements)(unsafe.Pointer(in.Resources))
return nil return nil
} }

View File

@ -441,7 +441,7 @@ func SetObjectDefaults_Pod(in *v1.Pod) {
SetDefaults_ResourceList(&in.Spec.Overhead) SetDefaults_ResourceList(&in.Spec.Overhead)
for i := range in.Status.InitContainerStatuses { for i := range in.Status.InitContainerStatuses {
a := &in.Status.InitContainerStatuses[i] a := &in.Status.InitContainerStatuses[i]
SetDefaults_ResourceList(&a.ResourcesAllocated) SetDefaults_ResourceList(&a.AllocatedResources)
if a.Resources != nil { if a.Resources != nil {
SetDefaults_ResourceList(&a.Resources.Limits) SetDefaults_ResourceList(&a.Resources.Limits)
SetDefaults_ResourceList(&a.Resources.Requests) SetDefaults_ResourceList(&a.Resources.Requests)
@ -449,7 +449,7 @@ func SetObjectDefaults_Pod(in *v1.Pod) {
} }
for i := range in.Status.ContainerStatuses { for i := range in.Status.ContainerStatuses {
a := &in.Status.ContainerStatuses[i] a := &in.Status.ContainerStatuses[i]
SetDefaults_ResourceList(&a.ResourcesAllocated) SetDefaults_ResourceList(&a.AllocatedResources)
if a.Resources != nil { if a.Resources != nil {
SetDefaults_ResourceList(&a.Resources.Limits) SetDefaults_ResourceList(&a.Resources.Limits)
SetDefaults_ResourceList(&a.Resources.Requests) SetDefaults_ResourceList(&a.Resources.Requests)
@ -457,7 +457,7 @@ func SetObjectDefaults_Pod(in *v1.Pod) {
} }
for i := range in.Status.EphemeralContainerStatuses { for i := range in.Status.EphemeralContainerStatuses {
a := &in.Status.EphemeralContainerStatuses[i] a := &in.Status.EphemeralContainerStatuses[i]
SetDefaults_ResourceList(&a.ResourcesAllocated) SetDefaults_ResourceList(&a.AllocatedResources)
if a.Resources != nil { if a.Resources != nil {
SetDefaults_ResourceList(&a.Resources.Limits) SetDefaults_ResourceList(&a.Resources.Limits)
SetDefaults_ResourceList(&a.Resources.Requests) SetDefaults_ResourceList(&a.Resources.Requests)
@ -475,7 +475,7 @@ func SetObjectDefaults_PodList(in *v1.PodList) {
func SetObjectDefaults_PodStatusResult(in *v1.PodStatusResult) { func SetObjectDefaults_PodStatusResult(in *v1.PodStatusResult) {
for i := range in.Status.InitContainerStatuses { for i := range in.Status.InitContainerStatuses {
a := &in.Status.InitContainerStatuses[i] a := &in.Status.InitContainerStatuses[i]
SetDefaults_ResourceList(&a.ResourcesAllocated) SetDefaults_ResourceList(&a.AllocatedResources)
if a.Resources != nil { if a.Resources != nil {
SetDefaults_ResourceList(&a.Resources.Limits) SetDefaults_ResourceList(&a.Resources.Limits)
SetDefaults_ResourceList(&a.Resources.Requests) SetDefaults_ResourceList(&a.Resources.Requests)
@ -483,7 +483,7 @@ func SetObjectDefaults_PodStatusResult(in *v1.PodStatusResult) {
} }
for i := range in.Status.ContainerStatuses { for i := range in.Status.ContainerStatuses {
a := &in.Status.ContainerStatuses[i] a := &in.Status.ContainerStatuses[i]
SetDefaults_ResourceList(&a.ResourcesAllocated) SetDefaults_ResourceList(&a.AllocatedResources)
if a.Resources != nil { if a.Resources != nil {
SetDefaults_ResourceList(&a.Resources.Limits) SetDefaults_ResourceList(&a.Resources.Limits)
SetDefaults_ResourceList(&a.Resources.Requests) SetDefaults_ResourceList(&a.Resources.Requests)
@ -491,7 +491,7 @@ func SetObjectDefaults_PodStatusResult(in *v1.PodStatusResult) {
} }
for i := range in.Status.EphemeralContainerStatuses { for i := range in.Status.EphemeralContainerStatuses {
a := &in.Status.EphemeralContainerStatuses[i] a := &in.Status.EphemeralContainerStatuses[i]
SetDefaults_ResourceList(&a.ResourcesAllocated) SetDefaults_ResourceList(&a.AllocatedResources)
if a.Resources != nil { if a.Resources != nil {
SetDefaults_ResourceList(&a.Resources.Limits) SetDefaults_ResourceList(&a.Resources.Limits)
SetDefaults_ResourceList(&a.Resources.Requests) SetDefaults_ResourceList(&a.Resources.Requests)

View File

@ -988,8 +988,8 @@ func (in *ContainerStatus) DeepCopyInto(out *ContainerStatus) {
*out = new(bool) *out = new(bool)
**out = **in **out = **in
} }
if in.ResourcesAllocated != nil { if in.AllocatedResources != nil {
in, out := &in.ResourcesAllocated, &out.ResourcesAllocated in, out := &in.AllocatedResources, &out.AllocatedResources
*out = make(ResourceList, len(*in)) *out = make(ResourceList, len(*in))
for key, val := range *in { for key, val := range *in {
(*out)[key] = val.DeepCopy() (*out)[key] = val.DeepCopy()

View File

@ -17649,9 +17649,9 @@ func schema_k8sio_api_core_v1_ContainerStatus(ref common.ReferenceCallback) comm
Format: "", Format: "",
}, },
}, },
"resourcesAllocated": { "allocatedResources": {
SchemaProps: spec.SchemaProps{ SchemaProps: spec.SchemaProps{
Description: "ResourcesAllocated represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.", Description: "AllocatedResources represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.",
Type: []string{"object"}, Type: []string{"object"},
AdditionalProperties: &spec.SchemaOrBool{ AdditionalProperties: &spec.SchemaOrBool{
Allows: true, Allows: true,

View File

@ -424,12 +424,12 @@ func (p *staticPolicy) guaranteedCPUs(pod *v1.Pod, container *v1.Container) int
} }
cpuQuantity := container.Resources.Requests[v1.ResourceCPU] cpuQuantity := container.Resources.Requests[v1.ResourceCPU]
// In-place pod resize feature makes Container.Resources field mutable for CPU & memory. // In-place pod resize feature makes Container.Resources field mutable for CPU & memory.
// ResourcesAllocated holds the value of Container.Resources.Requests when the pod was admitted. // AllocatedResources holds the value of Container.Resources.Requests when the pod was admitted.
// We should return this value because this is what kubelet agreed to allocate for the container // We should return this value because this is what kubelet agreed to allocate for the container
// and the value configured with runtime. // and the value configured with runtime.
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) { if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok { if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok {
cpuQuantity = cs.ResourcesAllocated[v1.ResourceCPU] cpuQuantity = cs.AllocatedResources[v1.ResourceCPU]
} }
} }
if cpuQuantity.Value()*1000 != cpuQuantity.MilliValue() { if cpuQuantity.Value()*1000 != cpuQuantity.MilliValue() {

View File

@ -415,12 +415,12 @@ func getRequestedResources(pod *v1.Pod, container *v1.Container) (map[v1.Resourc
requestedResources := map[v1.ResourceName]uint64{} requestedResources := map[v1.ResourceName]uint64{}
resources := container.Resources.Requests resources := container.Resources.Requests
// In-place pod resize feature makes Container.Resources field mutable for CPU & memory. // In-place pod resize feature makes Container.Resources field mutable for CPU & memory.
// ResourcesAllocated holds the value of Container.Resources.Requests when the pod was admitted. // AllocatedResources holds the value of Container.Resources.Requests when the pod was admitted.
// We should return this value because this is what kubelet agreed to allocate for the container // We should return this value because this is what kubelet agreed to allocate for the container
// and the value configured with runtime. // and the value configured with runtime.
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) { if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok { if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok {
resources = cs.ResourcesAllocated resources = cs.AllocatedResources
} }
} }
for resourceName, quantity := range resources { for resourceName, quantity := range resources {

View File

@ -1024,7 +1024,7 @@ func evictionMessage(resourceToReclaim v1.ResourceName, pod *v1.Pod, stats stats
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) && if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) &&
(resourceToReclaim == v1.ResourceMemory || resourceToReclaim == v1.ResourceCPU) { (resourceToReclaim == v1.ResourceMemory || resourceToReclaim == v1.ResourceCPU) {
if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok { if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok {
requests = cs.ResourcesAllocated[resourceToReclaim] requests = cs.AllocatedResources[resourceToReclaim]
} }
} }
var usage *resource.Quantity var usage *resource.Quantity

View File

@ -2134,7 +2134,7 @@ func TestEvictonMessageWithResourceResize(t *testing.T) {
ContainerStatuses: []v1.ContainerStatus{ ContainerStatuses: []v1.ContainerStatus{
{ {
Name: "testcontainer", Name: "testcontainer",
ResourcesAllocated: newResourceList("", "100Mi", ""), AllocatedResources: newResourceList("", "100Mi", ""),
}, },
}, },
} }

View File

@ -2129,10 +2129,10 @@ func (kl *Kubelet) canAdmitPod(pods []*v1.Pod, pod *v1.Pod) (bool, string, strin
for _, p := range pods { for _, p := range pods {
op := p.DeepCopy() op := p.DeepCopy()
for _, c := range op.Spec.Containers { for _, c := range op.Spec.Containers {
resourcesAllocated, found := kl.statusManager.GetContainerResourceAllocation(string(p.UID), c.Name) allocatedResources, found := kl.statusManager.GetContainerResourceAllocation(string(p.UID), c.Name)
if c.Resources.Requests != nil && found { if c.Resources.Requests != nil && found {
c.Resources.Requests[v1.ResourceCPU] = resourcesAllocated[v1.ResourceCPU] c.Resources.Requests[v1.ResourceCPU] = allocatedResources[v1.ResourceCPU]
c.Resources.Requests[v1.ResourceMemory] = resourcesAllocated[v1.ResourceMemory] c.Resources.Requests[v1.ResourceMemory] = allocatedResources[v1.ResourceMemory]
} }
} }
otherPods = append(otherPods, op) otherPods = append(otherPods, op)
@ -2422,14 +2422,14 @@ func (kl *Kubelet) HandlePodAdditions(pods []*v1.Pod) {
activePods := kl.filterOutInactivePods(existingPods) activePods := kl.filterOutInactivePods(existingPods)
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) { if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
// To handle kubelet restarts, test pod admissibility using ResourcesAllocated values // To handle kubelet restarts, test pod admissibility using AllocatedResources values
// (for cpu & memory) from checkpoint store. If found, that is the source of truth. // (for cpu & memory) from checkpoint store. If found, that is the source of truth.
podCopy := pod.DeepCopy() podCopy := pod.DeepCopy()
for _, c := range podCopy.Spec.Containers { for _, c := range podCopy.Spec.Containers {
resourcesAllocated, found := kl.statusManager.GetContainerResourceAllocation(string(pod.UID), c.Name) allocatedResources, found := kl.statusManager.GetContainerResourceAllocation(string(pod.UID), c.Name)
if c.Resources.Requests != nil && found { if c.Resources.Requests != nil && found {
c.Resources.Requests[v1.ResourceCPU] = resourcesAllocated[v1.ResourceCPU] c.Resources.Requests[v1.ResourceCPU] = allocatedResources[v1.ResourceCPU]
c.Resources.Requests[v1.ResourceMemory] = resourcesAllocated[v1.ResourceMemory] c.Resources.Requests[v1.ResourceMemory] = allocatedResources[v1.ResourceMemory]
} }
} }
// Check if we can admit the pod; if not, reject it. // Check if we can admit the pod; if not, reject it.
@ -2529,7 +2529,7 @@ func isPodResizeInProgress(pod *v1.Pod, podStatus *v1.PodStatus) bool {
continue continue
} }
if diff.ObjectDiff(c.Resources.Limits, cs.Resources.Limits) != "" || if diff.ObjectDiff(c.Resources.Limits, cs.Resources.Limits) != "" ||
diff.ObjectDiff(cs.ResourcesAllocated, cs.Resources.Requests) != "" { diff.ObjectDiff(cs.AllocatedResources, cs.Resources.Requests) != "" {
return true return true
} }
} }
@ -2574,7 +2574,7 @@ func (kl *Kubelet) canResizePod(pod *v1.Pod) (bool, *v1.Pod, v1.PodResizeStatus)
idx, found := podutil.GetIndexOfContainerStatus(podCopy.Status.ContainerStatuses, container.Name) idx, found := podutil.GetIndexOfContainerStatus(podCopy.Status.ContainerStatuses, container.Name)
if found { if found {
for rName, rQuantity := range container.Resources.Requests { for rName, rQuantity := range container.Resources.Requests {
podCopy.Status.ContainerStatuses[idx].ResourcesAllocated[rName] = rQuantity podCopy.Status.ContainerStatuses[idx].AllocatedResources[rName] = rQuantity
} }
} }
} }
@ -2595,11 +2595,11 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod) {
klog.V(5).InfoS("ContainerStatus not found", "pod", pod.Name, "container", container.Name) klog.V(5).InfoS("ContainerStatus not found", "pod", pod.Name, "container", container.Name)
break break
} }
if len(containerStatus.ResourcesAllocated) != len(container.Resources.Requests) { if len(containerStatus.AllocatedResources) != len(container.Resources.Requests) {
klog.V(5).InfoS("ContainerStatus.ResourcesAllocated length mismatch", "pod", pod.Name, "container", container.Name) klog.V(5).InfoS("ContainerStatus.AllocatedResources length mismatch", "pod", pod.Name, "container", container.Name)
break break
} }
if len(diff.ObjectDiff(container.Resources.Requests, containerStatus.ResourcesAllocated)) > 0 { if len(diff.ObjectDiff(container.Resources.Requests, containerStatus.AllocatedResources)) > 0 {
podResized = true podResized = true
break break
} }

View File

@ -1856,14 +1856,14 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
} }
} }
container := kubecontainer.GetContainerSpec(pod, cName) container := kubecontainer.GetContainerSpec(pod, cName)
// ResourcesAllocated values come from checkpoint. It is the source-of-truth. // AllocatedResources values come from checkpoint. It is the source-of-truth.
found := false found := false
status.ResourcesAllocated, found = kl.statusManager.GetContainerResourceAllocation(string(pod.UID), cName) status.AllocatedResources, found = kl.statusManager.GetContainerResourceAllocation(string(pod.UID), cName)
if !(container.Resources.Requests == nil && container.Resources.Limits == nil) && !found { if !(container.Resources.Requests == nil && container.Resources.Limits == nil) && !found {
// Log error and fallback to ResourcesAllocated in oldStatus if it exists // Log error and fallback to AllocatedResources in oldStatus if it exists
klog.ErrorS(nil, "resource allocation not found in checkpoint store", "pod", pod.Name, "container", cName) klog.ErrorS(nil, "resource allocation not found in checkpoint store", "pod", pod.Name, "container", cName)
if oldStatusFound { if oldStatusFound {
status.ResourcesAllocated = oldStatus.ResourcesAllocated status.AllocatedResources = oldStatus.AllocatedResources
} }
} }
if oldStatus.Resources == nil { if oldStatus.Resources == nil {
@ -1887,17 +1887,17 @@ func (kl *Kubelet) convertToAPIContainerStatuses(pod *v1.Pod, podStatus *kubecon
} }
} }
// Convert Requests // Convert Requests
if status.ResourcesAllocated != nil { if status.AllocatedResources != nil {
requests = make(v1.ResourceList) requests = make(v1.ResourceList)
if cStatus.Resources != nil && cStatus.Resources.CPURequest != nil { if cStatus.Resources != nil && cStatus.Resources.CPURequest != nil {
requests[v1.ResourceCPU] = cStatus.Resources.CPURequest.DeepCopy() requests[v1.ResourceCPU] = cStatus.Resources.CPURequest.DeepCopy()
} else { } else {
determineResource(v1.ResourceCPU, status.ResourcesAllocated, oldStatus.Resources.Requests, requests) determineResource(v1.ResourceCPU, status.AllocatedResources, oldStatus.Resources.Requests, requests)
} }
if memory, found := status.ResourcesAllocated[v1.ResourceMemory]; found { if memory, found := status.AllocatedResources[v1.ResourceMemory]; found {
requests[v1.ResourceMemory] = memory.DeepCopy() requests[v1.ResourceMemory] = memory.DeepCopy()
} }
if ephemeralStorage, found := status.ResourcesAllocated[v1.ResourceEphemeralStorage]; found { if ephemeralStorage, found := status.AllocatedResources[v1.ResourceEphemeralStorage]; found {
requests[v1.ResourceEphemeralStorage] = ephemeralStorage.DeepCopy() requests[v1.ResourceEphemeralStorage] = ephemeralStorage.DeepCopy()
} }
} }

View File

@ -4220,7 +4220,7 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
Image: "img", Image: "img",
ImageID: "img1234", ImageID: "img1234",
State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}}, State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}},
ResourcesAllocated: CPU1AndMem1G, AllocatedResources: CPU1AndMem1G,
Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1G, Requests: CPU1AndMem1G}, Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1G, Requests: CPU1AndMem1G},
}, },
}, },
@ -4243,7 +4243,7 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
Image: "img", Image: "img",
ImageID: "img1234", ImageID: "img1234",
State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}}, State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}},
ResourcesAllocated: CPU1AndMem1G, AllocatedResources: CPU1AndMem1G,
Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1G, Requests: CPU1AndMem1G}, Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1G, Requests: CPU1AndMem1G},
}, },
}, },
@ -4266,7 +4266,7 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
Image: "img", Image: "img",
ImageID: "img1234", ImageID: "img1234",
State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}}, State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}},
ResourcesAllocated: CPU1AndMem1GAndStorage2G, AllocatedResources: CPU1AndMem1GAndStorage2G,
Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1GAndStorage2G, Requests: CPU1AndMem1GAndStorage2G}, Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1GAndStorage2G, Requests: CPU1AndMem1GAndStorage2G},
}, },
}, },
@ -4289,7 +4289,7 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
Image: "img", Image: "img",
ImageID: "img1234", ImageID: "img1234",
State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}}, State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}},
ResourcesAllocated: CPU1AndMem1GAndStorage2G, AllocatedResources: CPU1AndMem1GAndStorage2G,
Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1GAndStorage2G, Requests: CPU1AndMem1GAndStorage2G}, Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1GAndStorage2G, Requests: CPU1AndMem1GAndStorage2G},
}, },
}, },
@ -4311,7 +4311,7 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
Image: "img", Image: "img",
ImageID: "img1234", ImageID: "img1234",
State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}}, State: v1.ContainerState{Running: &v1.ContainerStateRunning{StartedAt: metav1.NewTime(nowTime)}},
ResourcesAllocated: CPU1AndMem1GAndStorage2G, AllocatedResources: CPU1AndMem1GAndStorage2G,
Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1GAndStorage2G, Requests: CPU1AndMem1GAndStorage2G}, Resources: &v1.ResourceRequirements{Limits: CPU1AndMem1GAndStorage2G, Requests: CPU1AndMem1GAndStorage2G},
}, },
}, },
@ -4346,7 +4346,7 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
} }
kubelet.statusManager.SetPodAllocation(tPod) kubelet.statusManager.SetPodAllocation(tPod)
if tc.Resources != nil { if tc.Resources != nil {
tPod.Status.ContainerStatuses[i].ResourcesAllocated = tc.Resources[i].Requests tPod.Status.ContainerStatuses[i].AllocatedResources = tc.Resources[i].Requests
testPodStatus.ContainerStatuses[i].Resources = &kubecontainer.ContainerResources{ testPodStatus.ContainerStatuses[i].Resources = &kubecontainer.ContainerResources{
MemoryLimit: tc.Resources[i].Limits.Memory(), MemoryLimit: tc.Resources[i].Limits.Memory(),
CPULimit: tc.Resources[i].Limits.Cpu(), CPULimit: tc.Resources[i].Limits.Cpu(),

View File

@ -2494,7 +2494,7 @@ func TestHandlePodResourcesResize(t *testing.T) {
ContainerStatuses: []v1.ContainerStatus{ ContainerStatuses: []v1.ContainerStatus{
{ {
Name: "c1", Name: "c1",
ResourcesAllocated: v1.ResourceList{v1.ResourceCPU: cpu1000m, v1.ResourceMemory: mem1000M}, AllocatedResources: v1.ResourceList{v1.ResourceCPU: cpu1000m, v1.ResourceMemory: mem1000M},
Resources: &v1.ResourceRequirements{}, Resources: &v1.ResourceRequirements{},
}, },
}, },
@ -2584,9 +2584,9 @@ func TestHandlePodResourcesResize(t *testing.T) {
for _, tt := range tests { for _, tt := range tests {
tt.pod.Spec.Containers[0].Resources.Requests = tt.newRequests tt.pod.Spec.Containers[0].Resources.Requests = tt.newRequests
tt.pod.Status.ContainerStatuses[0].ResourcesAllocated = v1.ResourceList{v1.ResourceCPU: cpu1000m, v1.ResourceMemory: mem1000M} tt.pod.Status.ContainerStatuses[0].AllocatedResources = v1.ResourceList{v1.ResourceCPU: cpu1000m, v1.ResourceMemory: mem1000M}
kubelet.handlePodResourcesResize(tt.pod) kubelet.handlePodResourcesResize(tt.pod)
assert.Equal(t, tt.expectedAllocations, tt.pod.Status.ContainerStatuses[0].ResourcesAllocated, tt.name) assert.Equal(t, tt.expectedAllocations, tt.pod.Status.ContainerStatuses[0].AllocatedResources, tt.name)
assert.Equal(t, tt.expectedResize, tt.pod.Status.Resize, tt.name) assert.Equal(t, tt.expectedResize, tt.pod.Status.Resize, tt.name)
testKubelet.fakeKubeClient.ClearActions() testKubelet.fakeKubeClient.ClearActions()
} }

View File

@ -804,27 +804,27 @@ func TestGenerateLinuxContainerResources(t *testing.T) {
&runtimeapi.LinuxContainerResources{CpuShares: 2, OomScoreAdj: 1000}, &runtimeapi.LinuxContainerResources{CpuShares: 2, OomScoreAdj: 1000},
}, },
{ {
"requests & limits, cpu & memory, guaranteed qos - container status with resourcesAllocated", "requests & limits, cpu & memory, guaranteed qos - container status with allocatedResources",
true, true,
v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")},
v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")},
[]v1.ContainerStatus{ []v1.ContainerStatus{
{ {
Name: "c1", Name: "c1",
ResourcesAllocated: v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")}, AllocatedResources: v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")},
}, },
}, },
&runtimeapi.LinuxContainerResources{CpuShares: 204, MemoryLimitInBytes: 524288000, OomScoreAdj: -997}, &runtimeapi.LinuxContainerResources{CpuShares: 204, MemoryLimitInBytes: 524288000, OomScoreAdj: -997},
}, },
{ {
"requests & limits, cpu & memory, burstable qos - container status with resourcesAllocated", "requests & limits, cpu & memory, burstable qos - container status with allocatedResources",
true, true,
v1.ResourceList{v1.ResourceCPU: resource.MustParse("500m"), v1.ResourceMemory: resource.MustParse("750Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("500m"), v1.ResourceMemory: resource.MustParse("750Mi")},
v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")},
[]v1.ContainerStatus{ []v1.ContainerStatus{
{ {
Name: "c1", Name: "c1",
ResourcesAllocated: v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")}, AllocatedResources: v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")},
}, },
}, },
&runtimeapi.LinuxContainerResources{CpuShares: 256, MemoryLimitInBytes: 786432000, OomScoreAdj: 970}, &runtimeapi.LinuxContainerResources{CpuShares: 256, MemoryLimitInBytes: 786432000, OomScoreAdj: 970},
@ -838,27 +838,27 @@ func TestGenerateLinuxContainerResources(t *testing.T) {
&runtimeapi.LinuxContainerResources{CpuShares: 256, MemoryLimitInBytes: 524288000, OomScoreAdj: -997}, &runtimeapi.LinuxContainerResources{CpuShares: 256, MemoryLimitInBytes: 524288000, OomScoreAdj: -997},
}, },
{ {
"requests & limits, cpu & memory, burstable qos - container status with resourcesAllocated", "requests & limits, cpu & memory, burstable qos - container status with allocatedResources",
false, false,
v1.ResourceList{v1.ResourceCPU: resource.MustParse("500m"), v1.ResourceMemory: resource.MustParse("750Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("500m"), v1.ResourceMemory: resource.MustParse("750Mi")},
v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")},
[]v1.ContainerStatus{ []v1.ContainerStatus{
{ {
Name: "c1", Name: "c1",
ResourcesAllocated: v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")}, AllocatedResources: v1.ResourceList{v1.ResourceCPU: resource.MustParse("250m"), v1.ResourceMemory: resource.MustParse("500Mi")},
}, },
}, },
&runtimeapi.LinuxContainerResources{CpuShares: 256, MemoryLimitInBytes: 786432000, OomScoreAdj: 970}, &runtimeapi.LinuxContainerResources{CpuShares: 256, MemoryLimitInBytes: 786432000, OomScoreAdj: 970},
}, },
{ {
"requests & limits, cpu & memory, guaranteed qos - container status with resourcesAllocated", "requests & limits, cpu & memory, guaranteed qos - container status with allocatedResources",
false, false,
v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")},
v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")}, v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")},
[]v1.ContainerStatus{ []v1.ContainerStatus{
{ {
Name: "c1", Name: "c1",
ResourcesAllocated: v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")}, AllocatedResources: v1.ResourceList{v1.ResourceCPU: resource.MustParse("200m"), v1.ResourceMemory: resource.MustParse("500Mi")},
}, },
}, },
&runtimeapi.LinuxContainerResources{CpuShares: 204, MemoryLimitInBytes: 524288000, OomScoreAdj: -997}, &runtimeapi.LinuxContainerResources{CpuShares: 204, MemoryLimitInBytes: 524288000, OomScoreAdj: -997},

View File

@ -532,13 +532,13 @@ func (m *kubeGenericRuntimeManager) computePodResizeAction(pod *v1.Pod, containe
// Determine if the *running* container needs resource update by comparing v1.Spec.Resources (desired) // Determine if the *running* container needs resource update by comparing v1.Spec.Resources (desired)
// with v1.Status.Resources / runtime.Status.Resources (last known actual). // with v1.Status.Resources / runtime.Status.Resources (last known actual).
// Proceed only when kubelet has accepted the resize a.k.a v1.Spec.Resources.Requests == v1.Status.ResourcesAllocated. // Proceed only when kubelet has accepted the resize a.k.a v1.Spec.Resources.Requests == v1.Status.AllocatedResources.
// Skip if runtime containerID doesn't match pod.Status containerID (container is restarting) // Skip if runtime containerID doesn't match pod.Status containerID (container is restarting)
apiContainerStatus, exists := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name) apiContainerStatus, exists := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name)
if !exists || apiContainerStatus.State.Running == nil || apiContainerStatus.Resources == nil || if !exists || apiContainerStatus.State.Running == nil || apiContainerStatus.Resources == nil ||
kubeContainerStatus.State != kubecontainer.ContainerStateRunning || kubeContainerStatus.State != kubecontainer.ContainerStateRunning ||
kubeContainerStatus.ID.String() != apiContainerStatus.ContainerID || kubeContainerStatus.ID.String() != apiContainerStatus.ContainerID ||
len(diff.ObjectDiff(container.Resources.Requests, apiContainerStatus.ResourcesAllocated)) != 0 { len(diff.ObjectDiff(container.Resources.Requests, apiContainerStatus.AllocatedResources)) != 0 {
return true return true
} }
@ -569,7 +569,7 @@ func (m *kubeGenericRuntimeManager) computePodResizeAction(pod *v1.Pod, containe
desiredResources := containerResources{ desiredResources := containerResources{
memoryLimit: desiredMemoryLimit, memoryLimit: desiredMemoryLimit,
memoryRequest: apiContainerStatus.ResourcesAllocated.Memory().Value(), memoryRequest: apiContainerStatus.AllocatedResources.Memory().Value(),
cpuLimit: desiredCPULimit, cpuLimit: desiredCPULimit,
cpuRequest: desiredCPURequest, cpuRequest: desiredCPURequest,
} }

View File

@ -65,7 +65,7 @@ func GetContainerOOMScoreAdjust(pod *v1.Pod, container *v1.Container, memoryCapa
memoryRequest := container.Resources.Requests.Memory().Value() memoryRequest := container.Resources.Requests.Memory().Value()
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) { if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok { if cs, ok := podutil.GetContainerStatus(pod.Status.ContainerStatuses, container.Name); ok {
memoryRequest = cs.ResourcesAllocated.Memory().Value() memoryRequest = cs.AllocatedResources.Memory().Value()
} }
} }
oomScoreAdjust := 1000 - (1000*memoryRequest)/memoryCapacity oomScoreAdjust := 1000 - (1000*memoryRequest)/memoryCapacity

View File

@ -137,7 +137,7 @@ type Manager interface {
// the provided podUIDs. // the provided podUIDs.
RemoveOrphanedStatuses(podUIDs map[types.UID]bool) RemoveOrphanedStatuses(podUIDs map[types.UID]bool)
// GetContainerResourceAllocation returns checkpointed ResourcesAllocated value for the container // GetContainerResourceAllocation returns checkpointed AllocatedResources value for the container
GetContainerResourceAllocation(podUID string, containerName string) (v1.ResourceList, bool) GetContainerResourceAllocation(podUID string, containerName string) (v1.ResourceList, bool)
// GetPodResizeStatus returns checkpointed PodStatus.Resize value // GetPodResizeStatus returns checkpointed PodStatus.Resize value
@ -186,7 +186,7 @@ func isPodStatusByKubeletEqual(oldStatus, status *v1.PodStatus) bool {
} }
func (m *manager) Start() { func (m *manager) Start() {
// Create pod allocation checkpoint manager even if client is nil so as to allow local get/set of ResourcesAllocated & Resize // Create pod allocation checkpoint manager even if client is nil so as to allow local get/set of AllocatedResources & Resize
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) { if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) {
stateImpl, err := state.NewStateCheckpoint(m.stateFileDirectory, podStatusManagerStateFile) stateImpl, err := state.NewStateCheckpoint(m.stateFileDirectory, podStatusManagerStateFile)
if err != nil { if err != nil {
@ -232,7 +232,7 @@ func (m *manager) Start() {
}, 0) }, 0)
} }
// GetContainerResourceAllocation returns the last checkpointed ResourcesAllocated values // GetContainerResourceAllocation returns the last checkpointed AllocatedResources values
// If checkpoint manager has not been initialized, it returns nil, false // If checkpoint manager has not been initialized, it returns nil, false
func (m *manager) GetContainerResourceAllocation(podUID string, containerName string) (v1.ResourceList, bool) { func (m *manager) GetContainerResourceAllocation(podUID string, containerName string) (v1.ResourceList, bool) {
m.podStatusesLock.RLock() m.podStatusesLock.RLock()

View File

@ -763,7 +763,7 @@ func TestPodEvaluatorUsageResourceResize(t *testing.T) {
usageFgEnabled corev1.ResourceList usageFgEnabled corev1.ResourceList
usageFgDisabled corev1.ResourceList usageFgDisabled corev1.ResourceList
}{ }{
"verify Max(Container.Spec.Requests, ContainerStatus.ResourcesAllocated) for memory resource": { "verify Max(Container.Spec.Requests, ContainerStatus.AllocatedResources) for memory resource": {
pod: &api.Pod{ pod: &api.Pod{
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{
@ -782,7 +782,7 @@ func TestPodEvaluatorUsageResourceResize(t *testing.T) {
Status: api.PodStatus{ Status: api.PodStatus{
ContainerStatuses: []api.ContainerStatus{ ContainerStatuses: []api.ContainerStatus{
{ {
ResourcesAllocated: api.ResourceList{ AllocatedResources: api.ResourceList{
api.ResourceMemory: resource.MustParse("150Mi"), api.ResourceMemory: resource.MustParse("150Mi"),
}, },
}, },
@ -804,7 +804,7 @@ func TestPodEvaluatorUsageResourceResize(t *testing.T) {
generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"), generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"),
}, },
}, },
"verify Max(Container.Spec.Requests, ContainerStatus.ResourcesAllocated) for CPU resource": { "verify Max(Container.Spec.Requests, ContainerStatus.AllocatedResources) for CPU resource": {
pod: &api.Pod{ pod: &api.Pod{
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{
@ -823,7 +823,7 @@ func TestPodEvaluatorUsageResourceResize(t *testing.T) {
Status: api.PodStatus{ Status: api.PodStatus{
ContainerStatuses: []api.ContainerStatus{ ContainerStatuses: []api.ContainerStatus{
{ {
ResourcesAllocated: api.ResourceList{ AllocatedResources: api.ResourceList{
api.ResourceCPU: resource.MustParse("150m"), api.ResourceCPU: resource.MustParse("150m"),
}, },
}, },
@ -845,7 +845,7 @@ func TestPodEvaluatorUsageResourceResize(t *testing.T) {
generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"), generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"),
}, },
}, },
"verify Max(Container.Spec.Requests, ContainerStatus.ResourcesAllocated) for CPU and memory resource": { "verify Max(Container.Spec.Requests, ContainerStatus.AllocatedResources) for CPU and memory resource": {
pod: &api.Pod{ pod: &api.Pod{
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{
@ -866,7 +866,7 @@ func TestPodEvaluatorUsageResourceResize(t *testing.T) {
Status: api.PodStatus{ Status: api.PodStatus{
ContainerStatuses: []api.ContainerStatus{ ContainerStatuses: []api.ContainerStatus{
{ {
ResourcesAllocated: api.ResourceList{ AllocatedResources: api.ResourceList{
api.ResourceCPU: resource.MustParse("150m"), api.ResourceCPU: resource.MustParse("150m"),
api.ResourceMemory: resource.MustParse("250Mi"), api.ResourceMemory: resource.MustParse("250Mi"),
}, },
@ -895,7 +895,7 @@ func TestPodEvaluatorUsageResourceResize(t *testing.T) {
generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"), generic.ObjectCountQuotaResourceNameFor(schema.GroupResource{Resource: "pods"}): resource.MustParse("1"),
}, },
}, },
"verify Max(Container.Spec.Requests, ContainerStatus.ResourcesAllocated==nil) for CPU and memory resource": { "verify Max(Container.Spec.Requests, ContainerStatus.AllocatedResources==nil) for CPU and memory resource": {
pod: &api.Pod{ pod: &api.Pod{
Spec: api.PodSpec{ Spec: api.PodSpec{
Containers: []api.Container{ Containers: []api.Container{

View File

@ -1488,7 +1488,7 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
ContainerStatuses: []v1.ContainerStatus{ ContainerStatuses: []v1.ContainerStatus{
{ {
Name: "c1", Name: "c1",
ResourcesAllocated: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M}, AllocatedResources: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
}, },
}, },
}, },
@ -1497,7 +1497,7 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
tests := []struct { tests := []struct {
name string name string
requests v1.ResourceList requests v1.ResourceList
resourcesAllocated v1.ResourceList allocatedResources v1.ResourceList
resizeStatus v1.PodResizeStatus resizeStatus v1.PodResizeStatus
expectedResource Resource expectedResource Resource
expectedNon0CPU int64 expectedNon0CPU int64
@ -1506,7 +1506,7 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
{ {
name: "Pod with no pending resize", name: "Pod with no pending resize",
requests: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M}, requests: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
resourcesAllocated: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M}, allocatedResources: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
resizeStatus: "", resizeStatus: "",
expectedResource: Resource{MilliCPU: cpu500m.MilliValue(), Memory: mem500M.Value()}, expectedResource: Resource{MilliCPU: cpu500m.MilliValue(), Memory: mem500M.Value()},
expectedNon0CPU: cpu500m.MilliValue(), expectedNon0CPU: cpu500m.MilliValue(),
@ -1515,7 +1515,7 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
{ {
name: "Pod with resize in progress", name: "Pod with resize in progress",
requests: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M}, requests: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
resourcesAllocated: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M}, allocatedResources: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
resizeStatus: v1.PodResizeStatusInProgress, resizeStatus: v1.PodResizeStatusInProgress,
expectedResource: Resource{MilliCPU: cpu500m.MilliValue(), Memory: mem500M.Value()}, expectedResource: Resource{MilliCPU: cpu500m.MilliValue(), Memory: mem500M.Value()},
expectedNon0CPU: cpu500m.MilliValue(), expectedNon0CPU: cpu500m.MilliValue(),
@ -1524,7 +1524,7 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
{ {
name: "Pod with deferred resize", name: "Pod with deferred resize",
requests: v1.ResourceList{v1.ResourceCPU: cpu700m, v1.ResourceMemory: mem800M}, requests: v1.ResourceList{v1.ResourceCPU: cpu700m, v1.ResourceMemory: mem800M},
resourcesAllocated: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M}, allocatedResources: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
resizeStatus: v1.PodResizeStatusDeferred, resizeStatus: v1.PodResizeStatusDeferred,
expectedResource: Resource{MilliCPU: cpu700m.MilliValue(), Memory: mem800M.Value()}, expectedResource: Resource{MilliCPU: cpu700m.MilliValue(), Memory: mem800M.Value()},
expectedNon0CPU: cpu700m.MilliValue(), expectedNon0CPU: cpu700m.MilliValue(),
@ -1533,7 +1533,7 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
{ {
name: "Pod with infeasible resize", name: "Pod with infeasible resize",
requests: v1.ResourceList{v1.ResourceCPU: cpu700m, v1.ResourceMemory: mem800M}, requests: v1.ResourceList{v1.ResourceCPU: cpu700m, v1.ResourceMemory: mem800M},
resourcesAllocated: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M}, allocatedResources: v1.ResourceList{v1.ResourceCPU: cpu500m, v1.ResourceMemory: mem500M},
resizeStatus: v1.PodResizeStatusInfeasible, resizeStatus: v1.PodResizeStatusInfeasible,
expectedResource: Resource{MilliCPU: cpu500m.MilliValue(), Memory: mem500M.Value()}, expectedResource: Resource{MilliCPU: cpu500m.MilliValue(), Memory: mem500M.Value()},
expectedNon0CPU: cpu500m.MilliValue(), expectedNon0CPU: cpu500m.MilliValue(),
@ -1545,7 +1545,7 @@ func TestCalculatePodResourcesWithResize(t *testing.T) {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
pod := testpod.DeepCopy() pod := testpod.DeepCopy()
pod.Spec.Containers[0].Resources.Requests = tt.requests pod.Spec.Containers[0].Resources.Requests = tt.requests
pod.Status.ContainerStatuses[0].ResourcesAllocated = tt.resourcesAllocated pod.Status.ContainerStatuses[0].AllocatedResources = tt.allocatedResources
pod.Status.Resize = tt.resizeStatus pod.Status.Resize = tt.resizeStatus
res, non0CPU, non0Mem := calculateResource(pod) res, non0CPU, non0Mem := calculateResource(pod)

File diff suppressed because it is too large Load Diff

View File

@ -1004,12 +1004,12 @@ message ContainerStatus {
// +optional // +optional
optional bool started = 9; optional bool started = 9;
// ResourcesAllocated represents the compute resources allocated for this container by the // AllocatedResources represents the compute resources allocated for this container by the
// node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission // node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission
// and after successfully admitting desired pod resize. // and after successfully admitting desired pod resize.
// +featureGate=InPlacePodVerticalScaling // +featureGate=InPlacePodVerticalScaling
// +optional // +optional
map<string, k8s.io.apimachinery.pkg.api.resource.Quantity> resourcesAllocated = 10; map<string, k8s.io.apimachinery.pkg.api.resource.Quantity> allocatedResources = 10;
// Resources represents the compute resource requests and limits that have been successfully // Resources represents the compute resource requests and limits that have been successfully
// enacted on the running container after it has been started or has been successfully resized. // enacted on the running container after it has been started or has been successfully resized.

View File

@ -2710,12 +2710,12 @@ type ContainerStatus struct {
// same as false. // same as false.
// +optional // +optional
Started *bool `json:"started,omitempty" protobuf:"varint,9,opt,name=started"` Started *bool `json:"started,omitempty" protobuf:"varint,9,opt,name=started"`
// ResourcesAllocated represents the compute resources allocated for this container by the // AllocatedResources represents the compute resources allocated for this container by the
// node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission // node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission
// and after successfully admitting desired pod resize. // and after successfully admitting desired pod resize.
// +featureGate=InPlacePodVerticalScaling // +featureGate=InPlacePodVerticalScaling
// +optional // +optional
ResourcesAllocated ResourceList `json:"resourcesAllocated,omitempty" protobuf:"bytes,10,rep,name=resourcesAllocated,casttype=ResourceList,castkey=ResourceName"` AllocatedResources ResourceList `json:"allocatedResources,omitempty" protobuf:"bytes,10,rep,name=allocatedResources,casttype=ResourceList,castkey=ResourceName"`
// Resources represents the compute resource requests and limits that have been successfully // Resources represents the compute resource requests and limits that have been successfully
// enacted on the running container after it has been started or has been successfully resized. // enacted on the running container after it has been started or has been successfully resized.
// +featureGate=InPlacePodVerticalScaling // +featureGate=InPlacePodVerticalScaling

View File

@ -455,7 +455,7 @@ var map_ContainerStatus = map[string]string{
"imageID": "ImageID is the image ID of the container's image. The image ID may not match the image ID of the image used in the PodSpec, as it may have been resolved by the runtime.", "imageID": "ImageID is the image ID of the container's image. The image ID may not match the image ID of the image used in the PodSpec, as it may have been resolved by the runtime.",
"containerID": "ContainerID is the ID of the container in the format '<type>://<container_id>'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").", "containerID": "ContainerID is the ID of the container in the format '<type>://<container_id>'. Where type is a container runtime identifier, returned from Version call of CRI API (for example \"containerd\").",
"started": "Started indicates whether the container has finished its postStart lifecycle hook and passed its startup probe. Initialized as false, becomes true after startupProbe is considered successful. Resets to false when the container is restarted, or if kubelet loses state temporarily. In both cases, startup probes will run again. Is always true when no startupProbe is defined and container is running and has passed the postStart lifecycle hook. The null value must be treated the same as false.", "started": "Started indicates whether the container has finished its postStart lifecycle hook and passed its startup probe. Initialized as false, becomes true after startupProbe is considered successful. Resets to false when the container is restarted, or if kubelet loses state temporarily. In both cases, startup probes will run again. Is always true when no startupProbe is defined and container is running and has passed the postStart lifecycle hook. The null value must be treated the same as false.",
"resourcesAllocated": "ResourcesAllocated represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.", "allocatedResources": "AllocatedResources represents the compute resources allocated for this container by the node. Kubelet sets this value to Container.Resources.Requests upon successful pod admission and after successfully admitting desired pod resize.",
"resources": "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized.", "resources": "Resources represents the compute resource requests and limits that have been successfully enacted on the running container after it has been started or has been successfully resized.",
} }

View File

@ -988,8 +988,8 @@ func (in *ContainerStatus) DeepCopyInto(out *ContainerStatus) {
*out = new(bool) *out = new(bool)
**out = **in **out = **in
} }
if in.ResourcesAllocated != nil { if in.AllocatedResources != nil {
in, out := &in.ResourcesAllocated, &out.ResourcesAllocated in, out := &in.AllocatedResources, &out.AllocatedResources
*out = make(ResourceList, len(*in)) *out = make(ResourceList, len(*in))
for key, val := range *in { for key, val := range *in {
(*out)[key] = val.DeepCopy() (*out)[key] = val.DeepCopy()

View File

@ -1691,8 +1691,8 @@
"imageID": "imageIDValue", "imageID": "imageIDValue",
"containerID": "containerIDValue", "containerID": "containerIDValue",
"started": true, "started": true,
"resourcesAllocated": { "allocatedResources": {
"resourcesAllocatedKey": "0" "allocatedResourcesKey": "0"
}, },
"resources": { "resources": {
"limits": { "limits": {
@ -1754,8 +1754,8 @@
"imageID": "imageIDValue", "imageID": "imageIDValue",
"containerID": "containerIDValue", "containerID": "containerIDValue",
"started": true, "started": true,
"resourcesAllocated": { "allocatedResources": {
"resourcesAllocatedKey": "0" "allocatedResourcesKey": "0"
}, },
"resources": { "resources": {
"limits": { "limits": {
@ -1818,8 +1818,8 @@
"imageID": "imageIDValue", "imageID": "imageIDValue",
"containerID": "containerIDValue", "containerID": "containerIDValue",
"started": true, "started": true,
"resourcesAllocated": { "allocatedResources": {
"resourcesAllocatedKey": "0" "allocatedResourcesKey": "0"
}, },
"resources": { "resources": {
"limits": { "limits": {

View File

@ -1115,7 +1115,9 @@ status:
status: statusValue status: statusValue
type: typeValue type: typeValue
containerStatuses: containerStatuses:
- containerID: containerIDValue - allocatedResources:
allocatedResourcesKey: "0"
containerID: containerIDValue
image: imageValue image: imageValue
imageID: imageIDValue imageID: imageIDValue
lastState: lastState:
@ -1141,8 +1143,6 @@ status:
limitsKey: "0" limitsKey: "0"
requests: requests:
requestsKey: "0" requestsKey: "0"
resourcesAllocated:
resourcesAllocatedKey: "0"
restartCount: 5 restartCount: 5
started: true started: true
state: state:
@ -1160,7 +1160,9 @@ status:
message: messageValue message: messageValue
reason: reasonValue reason: reasonValue
ephemeralContainerStatuses: ephemeralContainerStatuses:
- containerID: containerIDValue - allocatedResources:
allocatedResourcesKey: "0"
containerID: containerIDValue
image: imageValue image: imageValue
imageID: imageIDValue imageID: imageIDValue
lastState: lastState:
@ -1186,8 +1188,6 @@ status:
limitsKey: "0" limitsKey: "0"
requests: requests:
requestsKey: "0" requestsKey: "0"
resourcesAllocated:
resourcesAllocatedKey: "0"
restartCount: 5 restartCount: 5
started: true started: true
state: state:
@ -1206,7 +1206,9 @@ status:
reason: reasonValue reason: reasonValue
hostIP: hostIPValue hostIP: hostIPValue
initContainerStatuses: initContainerStatuses:
- containerID: containerIDValue - allocatedResources:
allocatedResourcesKey: "0"
containerID: containerIDValue
image: imageValue image: imageValue
imageID: imageIDValue imageID: imageIDValue
lastState: lastState:
@ -1232,8 +1234,6 @@ status:
limitsKey: "0" limitsKey: "0"
requests: requests:
requestsKey: "0" requestsKey: "0"
resourcesAllocated:
resourcesAllocatedKey: "0"
restartCount: 5 restartCount: 5
started: true started: true
state: state:

View File

@ -111,8 +111,8 @@
"imageID": "imageIDValue", "imageID": "imageIDValue",
"containerID": "containerIDValue", "containerID": "containerIDValue",
"started": true, "started": true,
"resourcesAllocated": { "allocatedResources": {
"resourcesAllocatedKey": "0" "allocatedResourcesKey": "0"
}, },
"resources": { "resources": {
"limits": { "limits": {
@ -174,8 +174,8 @@
"imageID": "imageIDValue", "imageID": "imageIDValue",
"containerID": "containerIDValue", "containerID": "containerIDValue",
"started": true, "started": true,
"resourcesAllocated": { "allocatedResources": {
"resourcesAllocatedKey": "0" "allocatedResourcesKey": "0"
}, },
"resources": { "resources": {
"limits": { "limits": {
@ -238,8 +238,8 @@
"imageID": "imageIDValue", "imageID": "imageIDValue",
"containerID": "containerIDValue", "containerID": "containerIDValue",
"started": true, "started": true,
"resourcesAllocated": { "allocatedResources": {
"resourcesAllocatedKey": "0" "allocatedResourcesKey": "0"
}, },
"resources": { "resources": {
"limits": { "limits": {

View File

@ -41,7 +41,9 @@ status:
status: statusValue status: statusValue
type: typeValue type: typeValue
containerStatuses: containerStatuses:
- containerID: containerIDValue - allocatedResources:
allocatedResourcesKey: "0"
containerID: containerIDValue
image: imageValue image: imageValue
imageID: imageIDValue imageID: imageIDValue
lastState: lastState:
@ -67,8 +69,6 @@ status:
limitsKey: "0" limitsKey: "0"
requests: requests:
requestsKey: "0" requestsKey: "0"
resourcesAllocated:
resourcesAllocatedKey: "0"
restartCount: 5 restartCount: 5
started: true started: true
state: state:
@ -86,7 +86,9 @@ status:
message: messageValue message: messageValue
reason: reasonValue reason: reasonValue
ephemeralContainerStatuses: ephemeralContainerStatuses:
- containerID: containerIDValue - allocatedResources:
allocatedResourcesKey: "0"
containerID: containerIDValue
image: imageValue image: imageValue
imageID: imageIDValue imageID: imageIDValue
lastState: lastState:
@ -112,8 +114,6 @@ status:
limitsKey: "0" limitsKey: "0"
requests: requests:
requestsKey: "0" requestsKey: "0"
resourcesAllocated:
resourcesAllocatedKey: "0"
restartCount: 5 restartCount: 5
started: true started: true
state: state:
@ -132,7 +132,9 @@ status:
reason: reasonValue reason: reasonValue
hostIP: hostIPValue hostIP: hostIPValue
initContainerStatuses: initContainerStatuses:
- containerID: containerIDValue - allocatedResources:
allocatedResourcesKey: "0"
containerID: containerIDValue
image: imageValue image: imageValue
imageID: imageIDValue imageID: imageIDValue
lastState: lastState:
@ -158,8 +160,6 @@ status:
limitsKey: "0" limitsKey: "0"
requests: requests:
requestsKey: "0" requestsKey: "0"
resourcesAllocated:
resourcesAllocatedKey: "0"
restartCount: 5 restartCount: 5
started: true started: true
state: state:

View File

@ -34,7 +34,7 @@ type ContainerStatusApplyConfiguration struct {
ImageID *string `json:"imageID,omitempty"` ImageID *string `json:"imageID,omitempty"`
ContainerID *string `json:"containerID,omitempty"` ContainerID *string `json:"containerID,omitempty"`
Started *bool `json:"started,omitempty"` Started *bool `json:"started,omitempty"`
ResourcesAllocated *corev1.ResourceList `json:"resourcesAllocated,omitempty"` AllocatedResources *corev1.ResourceList `json:"allocatedResources,omitempty"`
Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"` Resources *ResourceRequirementsApplyConfiguration `json:"resources,omitempty"`
} }
@ -116,11 +116,11 @@ func (b *ContainerStatusApplyConfiguration) WithStarted(value bool) *ContainerSt
return b return b
} }
// WithResourcesAllocated sets the ResourcesAllocated field in the declarative configuration to the given value // WithAllocatedResources sets the AllocatedResources field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations. // and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the ResourcesAllocated field is set to the value of the last call. // If called multiple times, the AllocatedResources field is set to the value of the last call.
func (b *ContainerStatusApplyConfiguration) WithResourcesAllocated(value corev1.ResourceList) *ContainerStatusApplyConfiguration { func (b *ContainerStatusApplyConfiguration) WithAllocatedResources(value corev1.ResourceList) *ContainerStatusApplyConfiguration {
b.ResourcesAllocated = &value b.AllocatedResources = &value
return b return b
} }

View File

@ -4303,6 +4303,11 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.core.v1.ContainerStatus - name: io.k8s.api.core.v1.ContainerStatus
map: map:
fields: fields:
- name: allocatedResources
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: containerID - name: containerID
type: type:
scalar: string scalar: string
@ -4329,11 +4334,6 @@ var schemaYAML = typed.YAMLObject(`types:
- name: resources - name: resources
type: type:
namedType: io.k8s.api.core.v1.ResourceRequirements namedType: io.k8s.api.core.v1.ResourceRequirements
- name: resourcesAllocated
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: restartCount - name: restartCount
type: type:
scalar: numeric scalar: numeric

View File

@ -200,7 +200,7 @@ func makeTestContainer(tcInfo TestContainerInfo) (v1.Container, v1.ContainerStat
tcStatus := v1.ContainerStatus{ tcStatus := v1.ContainerStatus{
Name: tcInfo.Name, Name: tcInfo.Name,
ResourcesAllocated: alloc, AllocatedResources: alloc,
} }
return tc, tcStatus return tc, tcStatus
} }
@ -279,9 +279,9 @@ func verifyPodAllocations(pod *v1.Pod, tcInfo []TestContainerInfo, flagError boo
_, tcStatus := makeTestContainer(ci) _, tcStatus := makeTestContainer(ci)
if flagError { if flagError {
framework.ExpectEqual(tcStatus.ResourcesAllocated, cStatus.ResourcesAllocated) framework.ExpectEqual(tcStatus.AllocatedResources, cStatus.AllocatedResources)
} }
if diff.ObjectDiff(cStatus.ResourcesAllocated, tcStatus.ResourcesAllocated) != "" { if diff.ObjectDiff(cStatus.AllocatedResources, tcStatus.AllocatedResources) != "" {
return false return false
} }
} }