mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #81053 from oomichi/cleanup-indent-e2e-framework-metrics
Reduce indents of resource_usage_gatherer
This commit is contained in:
commit
a8d71390cf
@ -266,7 +266,9 @@ func NewResourceUsageGatherer(c clientset.Interface, options ResourceGathererOpt
|
|||||||
probeDuration: options.ProbeDuration,
|
probeDuration: options.ProbeDuration,
|
||||||
printVerboseLogs: options.PrintVerboseLogs,
|
printVerboseLogs: options.PrintVerboseLogs,
|
||||||
})
|
})
|
||||||
} else {
|
return &g, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Tracks kube-system pods if no valid PodList is passed in.
|
// Tracks kube-system pods if no valid PodList is passed in.
|
||||||
var err error
|
var err error
|
||||||
if pods == nil {
|
if pods == nil {
|
||||||
@ -320,7 +322,6 @@ func NewResourceUsageGatherer(c clientset.Interface, options ResourceGathererOpt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return &g, nil
|
return &g, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,11 +393,17 @@ func (g *ContainerResourceGatherer) StopAndSummarize(percentiles []int, constrai
|
|||||||
CPU: usage.CPUUsageInCores,
|
CPU: usage.CPUUsageInCores,
|
||||||
Mem: usage.MemoryWorkingSetInBytes,
|
Mem: usage.MemoryWorkingSetInBytes,
|
||||||
})
|
})
|
||||||
|
|
||||||
// Verifying 99th percentile of resource usage
|
// Verifying 99th percentile of resource usage
|
||||||
if perc == 99 {
|
if perc != 99 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
// Name has a form: <pod_name>/<container_name>
|
// Name has a form: <pod_name>/<container_name>
|
||||||
containerName := strings.Split(name, "/")[1]
|
containerName := strings.Split(name, "/")[1]
|
||||||
if constraint, ok := constraints[containerName]; ok {
|
constraint, ok := constraints[containerName]
|
||||||
|
if !ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
if usage.CPUUsageInCores > constraint.CPUConstraint {
|
if usage.CPUUsageInCores > constraint.CPUConstraint {
|
||||||
violatedConstraints = append(
|
violatedConstraints = append(
|
||||||
violatedConstraints,
|
violatedConstraints,
|
||||||
@ -419,8 +426,6 @@ func (g *ContainerResourceGatherer) StopAndSummarize(percentiles []int, constrai
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if len(violatedConstraints) > 0 {
|
if len(violatedConstraints) > 0 {
|
||||||
return &summary, fmt.Errorf(strings.Join(violatedConstraints, "\n"))
|
return &summary, fmt.Errorf(strings.Join(violatedConstraints, "\n"))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user