mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 12:43:23 +00:00
Reduce indents of resource_usage_gatherer
test/e2e/framework/resource_usage_gatherer contained much indents and they can be reduced with `continue` for code readability.
This commit is contained in:
parent
cc46849212
commit
de66a736e8
@ -266,7 +266,9 @@ func NewResourceUsageGatherer(c clientset.Interface, options ResourceGathererOpt
|
||||
probeDuration: options.ProbeDuration,
|
||||
printVerboseLogs: options.PrintVerboseLogs,
|
||||
})
|
||||
} else {
|
||||
return &g, nil
|
||||
}
|
||||
|
||||
// Tracks kube-system pods if no valid PodList is passed in.
|
||||
var err error
|
||||
if pods == nil {
|
||||
@ -320,7 +322,6 @@ func NewResourceUsageGatherer(c clientset.Interface, options ResourceGathererOpt
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return &g, nil
|
||||
}
|
||||
|
||||
@ -392,11 +393,17 @@ func (g *ContainerResourceGatherer) StopAndSummarize(percentiles []int, constrai
|
||||
CPU: usage.CPUUsageInCores,
|
||||
Mem: usage.MemoryWorkingSetInBytes,
|
||||
})
|
||||
|
||||
// Verifying 99th percentile of resource usage
|
||||
if perc == 99 {
|
||||
if perc != 99 {
|
||||
continue
|
||||
}
|
||||
// Name has a form: <pod_name>/<container_name>
|
||||
containerName := strings.Split(name, "/")[1]
|
||||
if constraint, ok := constraints[containerName]; ok {
|
||||
constraint, ok := constraints[containerName]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if usage.CPUUsageInCores > constraint.CPUConstraint {
|
||||
violatedConstraints = append(
|
||||
violatedConstraints,
|
||||
@ -419,8 +426,6 @@ func (g *ContainerResourceGatherer) StopAndSummarize(percentiles []int, constrai
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(violatedConstraints) > 0 {
|
||||
return &summary, fmt.Errorf(strings.Join(violatedConstraints, "\n"))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user