kubelet checkpoint: refactor state memory

refactor state mem constructor to accept the state as parameter
and SetPodAllocation to update a single pod.
This commit is contained in:
Filipe Xavier
2025-01-07 09:52:58 -03:00
parent 8e872978e8
commit efdd6bea2e
6 changed files with 35 additions and 23 deletions

View File

@@ -32,7 +32,7 @@ const testCheckpoint = "pod_status_manager_state"
func newTestStateCheckpoint(t *testing.T) *stateCheckpoint {
testingDir := getTestDir(t)
cache := NewStateMemory()
cache := NewStateMemory(PodResourceAllocation{}, PodResizeStatus{})
checkpointManager, err := checkpointmanager.NewCheckpointManager(testingDir)
require.NoError(t, err, "failed to create checkpoint manager")
checkpointName := "pod_state_checkpoint"
@@ -110,8 +110,10 @@ func Test_stateCheckpoint_storeState(t *testing.T) {
originalSC, err := NewStateCheckpoint(testDir, testCheckpoint)
require.NoError(t, err)
err = originalSC.SetPodResourceAllocation(tt.args.podResourceAllocation)
require.NoError(t, err)
for podUID, alloc := range tt.args.podResourceAllocation {
err = originalSC.SetPodResourceAllocation(podUID, alloc)
require.NoError(t, err)
}
actual := originalSC.GetPodResourceAllocation()
verifyPodResourceAllocation(t, &tt.args.podResourceAllocation, &actual, "stored pod resource allocation is not equal to original pod resource allocation")