mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-13 13:14:05 +00:00
cpuset: Delete 'builder' methods
All usage of builder pattern is convertible to cpuset.New() with the same or fewer lines of code. Migrate Builder.Add to a private method of CPUSet, with a comment that it is only intended for internal use to preserve immutable propoerty of the exported interface. This also removes 'require' library dependency, which avoids non-standard library usage.
This commit is contained in:
@@ -733,13 +733,12 @@ func validateSMTAlignment(cpus cpuset.CPUSet, smtLevel int, pod *v1.Pod, cnt *v1
|
||||
// now check all the given cpus are thread siblings.
|
||||
// to do so the easiest way is to rebuild the expected set of siblings from all the cpus we got.
|
||||
// if the expected set matches the given set, the given set was good.
|
||||
b := cpuset.NewBuilder()
|
||||
siblingsCPUs := cpuset.New()
|
||||
for _, cpuID := range cpus.UnsortedList() {
|
||||
threadSiblings, err := cpuset.Parse(strings.TrimSpace(getCPUSiblingList(int64(cpuID))))
|
||||
framework.ExpectNoError(err, "parsing cpuset from logs for [%s] of pod [%s]", cnt.Name, pod.Name)
|
||||
b.Add(threadSiblings.UnsortedList()...)
|
||||
siblingsCPUs = siblingsCPUs.Union(threadSiblings)
|
||||
}
|
||||
siblingsCPUs := b.Result()
|
||||
|
||||
framework.Logf("siblings cpus: %v", siblingsCPUs)
|
||||
if !siblingsCPUs.Equals(cpus) {
|
||||
|
@@ -522,11 +522,11 @@ func podresourcesGetAllocatableResourcesTests(ctx context.Context, cli kubeletpo
|
||||
resp, err := cli.GetAllocatableResources(ctx, &kubeletpodresourcesv1.AllocatableResourcesRequest{})
|
||||
framework.ExpectNoErrorWithOffset(1, err)
|
||||
devs := resp.GetDevices()
|
||||
b := cpuset.NewBuilder()
|
||||
var cpus []int
|
||||
for _, cpuid := range resp.GetCpuIds() {
|
||||
b.Add(int(cpuid))
|
||||
cpus = append(cpus, int(cpuid))
|
||||
}
|
||||
allocatableCPUs := b.Result()
|
||||
allocatableCPUs := cpuset.New(cpus...)
|
||||
|
||||
if onlineCPUs.Size() == 0 {
|
||||
ginkgo.By("expecting no CPUs reported")
|
||||
|
Reference in New Issue
Block a user