mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Cleanup unused container parameter from allocation state Delete
This commit is contained in:
parent
05a9c06212
commit
e8547d8a54
@ -176,12 +176,12 @@ func allocationFromPod(pod *v1.Pod) map[string]v1.ResourceRequirements {
|
||||
}
|
||||
|
||||
func (m *manager) RemovePod(uid types.UID) {
|
||||
if err := m.allocated.Delete(uid, ""); err != nil {
|
||||
if err := m.allocated.RemovePod(uid); err != nil {
|
||||
// If the deletion fails, it will be retried by RemoveOrphanedPods, so we can safely ignore the error.
|
||||
klog.V(3).ErrorS(err, "Failed to delete pod allocation", "podUID", uid)
|
||||
}
|
||||
|
||||
if err := m.actuated.Delete(uid, ""); err != nil {
|
||||
if err := m.actuated.RemovePod(uid); err != nil {
|
||||
// If the deletion fails, it will be retried by RemoveOrphanedPods, so we can safely ignore the error.
|
||||
klog.V(3).ErrorS(err, "Failed to delete pod allocation", "podUID", uid)
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ type Reader interface {
|
||||
type writer interface {
|
||||
SetContainerResourceAllocation(podUID types.UID, containerName string, alloc v1.ResourceRequirements) error
|
||||
SetPodResourceAllocation(podUID types.UID, alloc map[string]v1.ResourceRequirements) error
|
||||
Delete(podUID types.UID, containerName string) error
|
||||
RemovePod(podUID types.UID) error
|
||||
// RemoveOrphanedPods removes the stored state for any pods not included in the set of remaining pods.
|
||||
RemoveOrphanedPods(remainingPods sets.Set[types.UID])
|
||||
}
|
||||
|
@ -139,13 +139,13 @@ func (sc *stateCheckpoint) SetPodResourceAllocation(podUID types.UID, alloc map[
|
||||
}
|
||||
|
||||
// Delete deletes allocations for specified pod
|
||||
func (sc *stateCheckpoint) Delete(podUID types.UID, containerName string) error {
|
||||
func (sc *stateCheckpoint) RemovePod(podUID types.UID) error {
|
||||
sc.mux.Lock()
|
||||
defer sc.mux.Unlock()
|
||||
// Skip writing the checkpoint for pod deletion, since there is no side effect to
|
||||
// keeping a deleted pod. Deleted pods will eventually be cleaned up by RemoveOrphanedPods.
|
||||
// The deletion will be stored the next time a non-delete update is made.
|
||||
return sc.cache.Delete(podUID, "")
|
||||
return sc.cache.RemovePod(podUID)
|
||||
}
|
||||
|
||||
func (sc *stateCheckpoint) RemoveOrphanedPods(remainingPods sets.Set[types.UID]) {
|
||||
@ -177,7 +177,7 @@ func (sc *noopStateCheckpoint) SetPodResourceAllocation(_ types.UID, _ map[strin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (sc *noopStateCheckpoint) Delete(_ types.UID, _ string) error {
|
||||
func (sc *noopStateCheckpoint) RemovePod(_ types.UID) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -79,23 +79,11 @@ func (s *stateMemory) SetPodResourceAllocation(podUID types.UID, alloc map[strin
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *stateMemory) deleteContainer(podUID types.UID, containerName string) {
|
||||
delete(s.podAllocation[podUID], containerName)
|
||||
if len(s.podAllocation[podUID]) == 0 {
|
||||
delete(s.podAllocation, podUID)
|
||||
}
|
||||
klog.V(3).InfoS("Deleted pod resource allocation", "podUID", podUID, "containerName", containerName)
|
||||
}
|
||||
|
||||
func (s *stateMemory) Delete(podUID types.UID, containerName string) error {
|
||||
func (s *stateMemory) RemovePod(podUID types.UID) error {
|
||||
s.Lock()
|
||||
defer s.Unlock()
|
||||
if len(containerName) == 0 {
|
||||
delete(s.podAllocation, podUID)
|
||||
klog.V(3).InfoS("Deleted pod resource allocation and resize state", "podUID", podUID)
|
||||
return nil
|
||||
}
|
||||
s.deleteContainer(podUID, containerName)
|
||||
delete(s.podAllocation, podUID)
|
||||
klog.V(3).InfoS("Deleted pod resource allocation", "podUID", podUID)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user