delete unused functions in pkg directory

This commit is contained in:
HirazawaUi
2023-01-16 21:29:12 +08:00
parent 4c4d4ad0a4
commit 3b18e80fb4
8 changed files with 0 additions and 155 deletions

View File

@@ -60,78 +60,3 @@ func MakeNodesAndPodsForEvenPodsSpread(labels map[string]string, existingPodsNum
}
return
}
// MakeNodesAndPodsForPodAffinity serves as a testing helper for Pod(Anti)Affinity feature.
// It builds a fake cluster containing running Pods and Nodes.
// For simplicity, the Nodes will be labelled with "region", "zone" and "node". Nodes[i] will be applied with:
// - "region": "region" + i%3
// - "zone": "zone" + i%10
// - "node": "node" + i
// The Pods will be applied with various combinations of PodAffinity and PodAntiAffinity terms.
func MakeNodesAndPodsForPodAffinity(existingPodsNum, allNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node) {
tpKeyToSizeMap := map[string]int{
"region": 3,
"zone": 10,
"node": allNodesNum,
}
// build nodes to spread across all topology domains
for i := 0; i < allNodesNum; i++ {
nodeName := fmt.Sprintf("node%d", i)
nodeWrapper := MakeNode().Name(nodeName)
for tpKey, size := range tpKeyToSizeMap {
nodeWrapper = nodeWrapper.Label(tpKey, fmt.Sprintf("%s%d", tpKey, i%size))
}
allNodes = append(allNodes, nodeWrapper.Obj())
}
labels := []string{"foo", "bar", "baz"}
tpKeys := []string{"region", "zone", "node"}
// Build pods.
// Each pod will be created with one affinity and one anti-affinity terms using all combinations of
// affinity and anti-affinity kinds listed below
// e.g., the first pod will have {affinity, anti-affinity} terms of kinds {NilPodAffinity, NilPodAffinity};
// the second will be {NilPodAffinity, PodAntiAffinityWithRequiredReq}, etc.
affinityKinds := []PodAffinityKind{
NilPodAffinity,
PodAffinityWithRequiredReq,
PodAffinityWithPreferredReq,
PodAffinityWithRequiredPreferredReq,
}
antiAffinityKinds := []PodAffinityKind{
NilPodAffinity,
PodAntiAffinityWithRequiredReq,
PodAntiAffinityWithPreferredReq,
PodAntiAffinityWithRequiredPreferredReq,
}
totalSize := len(affinityKinds) * len(antiAffinityKinds)
for i := 0; i < existingPodsNum; i++ {
podWrapper := MakePod().Name(fmt.Sprintf("pod%d", i)).Node(fmt.Sprintf("node%d", i%allNodesNum))
label, tpKey := labels[i%len(labels)], tpKeys[i%len(tpKeys)]
affinityIdx := i % totalSize
// len(affinityKinds) is equal to len(antiAffinityKinds)
leftIdx, rightIdx := affinityIdx/len(affinityKinds), affinityIdx%len(affinityKinds)
podWrapper = podWrapper.PodAffinityExists(label, tpKey, affinityKinds[leftIdx])
podWrapper = podWrapper.PodAntiAffinityExists(label, tpKey, antiAffinityKinds[rightIdx])
existingPods = append(existingPods, podWrapper.Obj())
}
return
}
// MakeNodesAndPods serves as a testing helper to generate regular Nodes and Pods
// that don't use any advanced scheduling features.
func MakeNodesAndPods(existingPodsNum, allNodesNum int) (existingPods []*v1.Pod, allNodes []*v1.Node) {
// build nodes
for i := 0; i < allNodesNum; i++ {
allNodes = append(allNodes, MakeNode().Name(fmt.Sprintf("node%d", i)).Obj())
}
// build pods
for i := 0; i < existingPodsNum; i++ {
podWrapper := MakePod().Name(fmt.Sprintf("pod%d", i)).Node(fmt.Sprintf("node%d", i%allNodesNum))
existingPods = append(existingPods, podWrapper.Obj())
}
return
}