Commit 7d8cb3d0 authored by zounengren's avatar zounengren
Browse files

using map instead

Signed-off-by: default avatarzounengren <zouyee1989@gmail.com>
parent abdb63c3
Showing with 3 additions and 1 deletion
+3 -1
......@@ -29,6 +29,7 @@ func (c *EffectiveVPAController) ReconcileContainerPolicies(evpa *autoscalingapi
rankedEstimators := RankEstimators(resourceEstimators)
needReconciledContainers := make(map[string]autoscalingapi.ContainerResourcePolicy)
containerResourceRequirement := make(map[string]*corev1.ResourceRequirements)
for _, container := range podTemplate.Spec.Containers {
for _, containerPolicy := range evpa.Spec.ResourcePolicy.ContainerPolicies {
if containerPolicy.ContainerName == "*" || containerPolicy.ContainerName == container.Name {
......@@ -37,10 +38,11 @@ func (c *EffectiveVPAController) ReconcileContainerPolicies(evpa *autoscalingapi
needReconciledContainers[container.Name] = *out
}
}
containerResourceRequirement[container.Name] = &container.Resources
}
for container, containerPolicy := range needReconciledContainers {
// get current resource by pod template
resourceRequirement, found := utils.GetResourceByPodTemplate(podTemplate, container)
resourceRequirement, found := containerResourceRequirement[container]
if !found {
klog.Warningf("ContainerName %s not found", containerPolicy.ContainerName)
continue
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment