Delete unused ResizeContainerPatch function

This commit is contained in:
Tim Allclair
2025-07-07 13:59:32 -07:00
parent f1b35cae91
commit ae7d637b89

View File

@@ -53,29 +53,6 @@ type ResizableContainerInfo struct {
InitCtr bool
}
type containerPatch struct {
Name string `json:"name"`
Resources struct {
Requests struct {
CPU string `json:"cpu,omitempty"`
Memory string `json:"memory,omitempty"`
EphStor string `json:"ephemeral-storage,omitempty"`
} `json:"requests,omitzero"`
Limits struct {
CPU string `json:"cpu,omitempty"`
Memory string `json:"memory,omitempty"`
EphStor string `json:"ephemeral-storage,omitempty"`
} `json:"limits,omitzero"`
} `json:"resources"`
}
type patchSpec struct {
Spec struct {
Containers []containerPatch `json:"containers,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
InitContainers []containerPatch `json:"initContainers,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
} `json:"spec"`
}
func getTestResizePolicy(tcInfo ResizableContainerInfo) (resizePol []v1.ContainerResizePolicy) {
if tcInfo.CPUPolicy != nil {
cpuPol := v1.ContainerResizePolicy{ResourceName: v1.ResourceCPU, RestartPolicy: *tcInfo.CPUPolicy}
@@ -371,33 +348,6 @@ func ExpectPodResized(ctx context.Context, f *framework.Framework, resizedPod *v
}
}
// ResizeContainerPatch generates a patch string to resize the pod container.
func ResizeContainerPatch(containers []ResizableContainerInfo) ([]byte, error) {
var patch patchSpec
for _, container := range containers {
var cPatch containerPatch
cPatch.Name = container.Name
cPatch.Resources.Requests.CPU = container.Resources.CPUReq
cPatch.Resources.Requests.Memory = container.Resources.MemReq
cPatch.Resources.Limits.CPU = container.Resources.CPULim
cPatch.Resources.Limits.Memory = container.Resources.MemLim
if container.InitCtr {
patch.Spec.InitContainers = append(patch.Spec.InitContainers, cPatch)
} else {
patch.Spec.Containers = append(patch.Spec.Containers, cPatch)
}
}
patchBytes, err := json.Marshal(patch)
if err != nil {
return nil, err
}
return patchBytes, nil
}
func MakeResizePatch(originalContainers, desiredContainers []ResizableContainerInfo) []byte {
original, err := json.Marshal(MakePodWithResizableContainers("", "", "", originalContainers))
framework.ExpectNoError(err)