Skip to content

Commit 6d0b627

Browse files
committed
Rename some allocation.Manager methods
1 parent d4444dd commit 6d0b627

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

pkg/kubelet/allocation/allocation_manager.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ type Manager interface {
4646
// Returns the updated (or original) pod, and whether there was an allocation stored.
4747
UpdatePodFromAllocation(pod *v1.Pod) (*v1.Pod, bool)
4848

49-
// SetPodAllocation checkpoints the resources allocated to a pod's containers.
50-
SetPodAllocation(allocatedPod *v1.Pod) error
49+
// SetAllocatedResources checkpoints the resources allocated to a pod's containers.
50+
SetAllocatedResources(allocatedPod *v1.Pod) error
5151

5252
// SetActuatedResources records the actuated resources of the given container (or the entire
5353
// pod, if actuatedContainer is nil).
@@ -56,8 +56,8 @@ type Manager interface {
5656
// GetActuatedResources returns the stored actuated resources for the container, and whether they exist.
5757
GetActuatedResources(podUID types.UID, containerName string) (v1.ResourceRequirements, bool)
5858

59-
// DeletePod removes any stored state for the given pod UID.
60-
DeletePod(uid types.UID)
59+
// RemovePod removes any stored state for the given pod UID.
60+
RemovePod(uid types.UID)
6161

6262
// RemoveOrphanedPods removes the stored state for any pods not included in the set of remaining pods.
6363
RemoveOrphanedPods(remainingPods sets.Set[types.UID])
@@ -151,8 +151,8 @@ func updatePodFromAllocation(pod *v1.Pod, allocs state.PodResourceAllocation) (*
151151
return pod, updated
152152
}
153153

154-
// SetPodAllocation checkpoints the resources allocated to a pod's containers
155-
func (m *manager) SetPodAllocation(pod *v1.Pod) error {
154+
// SetAllocatedResources checkpoints the resources allocated to a pod's containers
155+
func (m *manager) SetAllocatedResources(pod *v1.Pod) error {
156156
return m.allocated.SetPodResourceAllocation(pod.UID, allocationFromPod(pod))
157157
}
158158

@@ -175,7 +175,7 @@ func allocationFromPod(pod *v1.Pod) map[string]v1.ResourceRequirements {
175175
return podAlloc
176176
}
177177

178-
func (m *manager) DeletePod(uid types.UID) {
178+
func (m *manager) RemovePod(uid types.UID) {
179179
if err := m.allocated.Delete(uid, ""); err != nil {
180180
// If the deletion fails, it will be retried by RemoveOrphanedPods, so we can safely ignore the error.
181181
klog.V(3).ErrorS(err, "Failed to delete pod allocation", "podUID", uid)

pkg/kubelet/kubelet.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2667,7 +2667,7 @@ func (kl *Kubelet) HandlePodAdditions(pods []*v1.Pod) {
26672667
continue
26682668
}
26692669
// For new pod, checkpoint the resource values at which the Pod has been admitted
2670-
if err := kl.allocationManager.SetPodAllocation(allocatedPod); err != nil {
2670+
if err := kl.allocationManager.SetAllocatedResources(allocatedPod); err != nil {
26712671
//TODO(vinaykul,InPlacePodVerticalScaling): Can we recover from this in some way? Investigate
26722672
klog.ErrorS(err, "SetPodAllocation failed", "pod", klog.KObj(pod))
26732673
}
@@ -2723,7 +2723,7 @@ func (kl *Kubelet) HandlePodRemoves(pods []*v1.Pod) {
27232723
start := kl.clock.Now()
27242724
for _, pod := range pods {
27252725
kl.podManager.RemovePod(pod)
2726-
kl.allocationManager.DeletePod(pod.UID)
2726+
kl.allocationManager.RemovePod(pod.UID)
27272727

27282728
pod, mirrorPod, wasMirror := kl.podManager.GetPodAndMirrorPod(pod)
27292729
if wasMirror {
@@ -2909,7 +2909,7 @@ func (kl *Kubelet) handlePodResourcesResize(pod *v1.Pod, podStatus *kubecontaine
29092909
fit, resizeStatus, resizeMsg := kl.canResizePod(pod)
29102910
if fit {
29112911
// Update pod resource allocation checkpoint
2912-
if err := kl.allocationManager.SetPodAllocation(pod); err != nil {
2912+
if err := kl.allocationManager.SetAllocatedResources(pod); err != nil {
29132913
return nil, err
29142914
}
29152915
for i, container := range pod.Spec.Containers {

pkg/kubelet/kubelet_pods_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5093,7 +5093,7 @@ func TestConvertToAPIContainerStatusesForResources(t *testing.T) {
50935093
} else {
50945094
tPod.Spec.Containers[0].Resources = tc.Resources
50955095
}
5096-
err := kubelet.allocationManager.SetPodAllocation(tPod)
5096+
err := kubelet.allocationManager.SetAllocatedResources(tPod)
50975097
require.NoError(t, err)
50985098
resources := tc.ActualResources
50995099
if resources == nil {

pkg/kubelet/kubelet_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2568,7 +2568,7 @@ func TestPodResourceAllocationReset(t *testing.T) {
25682568
t.Run(tc.name, func(t *testing.T) {
25692569
if tc.existingPodAllocation != nil {
25702570
// when kubelet restarts, AllocatedResources has already existed before adding pod
2571-
err := kubelet.allocationManager.SetPodAllocation(tc.existingPodAllocation)
2571+
err := kubelet.allocationManager.SetAllocatedResources(tc.existingPodAllocation)
25722572
if err != nil {
25732573
t.Fatalf("failed to set pod allocation: %v", err)
25742574
}
@@ -2858,12 +2858,12 @@ func TestHandlePodResourcesResize(t *testing.T) {
28582858
}
28592859

28602860
if !tt.newResourcesAllocated {
2861-
require.NoError(t, kubelet.allocationManager.SetPodAllocation(originalPod))
2861+
require.NoError(t, kubelet.allocationManager.SetAllocatedResources(originalPod))
28622862
} else {
2863-
require.NoError(t, kubelet.allocationManager.SetPodAllocation(newPod))
2863+
require.NoError(t, kubelet.allocationManager.SetAllocatedResources(newPod))
28642864
}
28652865
require.NoError(t, kubelet.allocationManager.SetActuatedResources(originalPod, nil))
2866-
t.Cleanup(func() { kubelet.allocationManager.DeletePod(originalPod.UID) })
2866+
t.Cleanup(func() { kubelet.allocationManager.RemovePod(originalPod.UID) })
28672867

28682868
podStatus := &kubecontainer.PodStatus{
28692869
ID: originalPod.UID,
@@ -3882,7 +3882,7 @@ func TestIsPodResizeInProgress(t *testing.T) {
38823882
UID: "12345",
38833883
},
38843884
}
3885-
t.Cleanup(func() { am.DeletePod(pod.UID) })
3885+
t.Cleanup(func() { am.RemovePod(pod.UID) })
38863886
podStatus := &kubecontainer.PodStatus{
38873887
ID: pod.UID,
38883888
Name: pod.Name,
@@ -3923,7 +3923,7 @@ func TestIsPodResizeInProgress(t *testing.T) {
39233923
require.False(t, found)
39243924
}
39253925
}
3926-
require.NoError(t, am.SetPodAllocation(pod))
3926+
require.NoError(t, am.SetAllocatedResources(pod))
39273927

39283928
hasResizedResources := kl.isPodResizeInProgress(pod, podStatus)
39293929
require.Equal(t, test.expectHasResize, hasResizedResources, "hasResizedResources")

pkg/kubelet/kuberuntime/kuberuntime_manager_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2898,7 +2898,7 @@ func TestComputePodActionsForPodResize(t *testing.T) {
28982898
if test.setupFn != nil {
28992899
test.setupFn(pod)
29002900
}
2901-
t.Cleanup(func() { m.allocationManager.DeletePod(pod.UID) })
2901+
t.Cleanup(func() { m.allocationManager.RemovePod(pod.UID) })
29022902

29032903
for idx := range pod.Spec.Containers {
29042904
// compute hash

0 commit comments

Comments
 (0)