@@ -43,7 +43,7 @@ func NewStateCheckpoint(stateDir, checkpointName string) (State, error) {
43
43
return nil , fmt .Errorf ("failed to initialize checkpoint manager for pod allocation tracking: %v" , err )
44
44
}
45
45
stateCheckpoint := & stateCheckpoint {
46
- cache : NewStateMemory (),
46
+ cache : NewStateMemory (PodResourceAllocation {}, PodResizeStatus {} ),
47
47
checkpointManager : checkpointManager ,
48
48
checkpointName : checkpointName ,
49
49
}
@@ -76,10 +76,14 @@ func (sc *stateCheckpoint) restoreState() error {
76
76
if err != nil {
77
77
return fmt .Errorf ("failed to get pod resource allocation info: %w" , err )
78
78
}
79
- err = sc .cache .SetPodResourceAllocation (praInfo .AllocationEntries )
80
- if err != nil {
81
- return fmt .Errorf ("failed to set pod resource allocation: %w" , err )
79
+
80
+ for podUID , alloc := range praInfo .AllocationEntries {
81
+ err = sc .cache .SetPodResourceAllocation (podUID , alloc )
82
+ if err != nil {
83
+ klog .ErrorS (err , "failed to set pod resource allocation" )
84
+ }
82
85
}
86
+
83
87
klog .V (2 ).InfoS ("State checkpoint: restored pod resource allocation state from checkpoint" )
84
88
return nil
85
89
}
@@ -132,10 +136,15 @@ func (sc *stateCheckpoint) SetContainerResourceAllocation(podUID string, contain
132
136
}
133
137
134
138
// SetPodResourceAllocation sets pod resource allocation
135
- func (sc * stateCheckpoint ) SetPodResourceAllocation (a PodResourceAllocation ) error {
139
+ func (sc * stateCheckpoint ) SetPodResourceAllocation (podUID string , alloc map [ string ]v1. ResourceRequirements ) error {
136
140
sc .mux .Lock ()
137
141
defer sc .mux .Unlock ()
138
- sc .cache .SetPodResourceAllocation (a )
142
+
143
+ err := sc .cache .SetPodResourceAllocation (podUID , alloc )
144
+ if err != nil {
145
+ return err
146
+ }
147
+
139
148
return sc .storeState ()
140
149
}
141
150
@@ -185,7 +194,7 @@ func (sc *noopStateCheckpoint) SetContainerResourceAllocation(_ string, _ string
185
194
return nil
186
195
}
187
196
188
- func (sc * noopStateCheckpoint ) SetPodResourceAllocation (_ PodResourceAllocation ) error {
197
+ func (sc * noopStateCheckpoint ) SetPodResourceAllocation (_ string , _ map [ string ]v1. ResourceRequirements ) error {
189
198
return nil
190
199
}
191
200
0 commit comments