mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Cleanup unused container parameter from allocation state Delete
This commit is contained in:
		@@ -176,12 +176,12 @@ func allocationFromPod(pod *v1.Pod) map[string]v1.ResourceRequirements {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (m *manager) RemovePod(uid types.UID) {
 | 
					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.
 | 
							// 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)
 | 
							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.
 | 
							// 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)
 | 
							klog.V(3).ErrorS(err, "Failed to delete pod allocation", "podUID", uid)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ type Reader interface {
 | 
				
			|||||||
type writer interface {
 | 
					type writer interface {
 | 
				
			||||||
	SetContainerResourceAllocation(podUID types.UID, containerName string, alloc v1.ResourceRequirements) error
 | 
						SetContainerResourceAllocation(podUID types.UID, containerName string, alloc v1.ResourceRequirements) error
 | 
				
			||||||
	SetPodResourceAllocation(podUID types.UID, alloc map[string]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 removes the stored state for any pods not included in the set of remaining pods.
 | 
				
			||||||
	RemoveOrphanedPods(remainingPods sets.Set[types.UID])
 | 
						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
 | 
					// 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()
 | 
						sc.mux.Lock()
 | 
				
			||||||
	defer sc.mux.Unlock()
 | 
						defer sc.mux.Unlock()
 | 
				
			||||||
	// Skip writing the checkpoint for pod deletion, since there is no side effect to
 | 
						// 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.
 | 
						// 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.
 | 
						// 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]) {
 | 
					func (sc *stateCheckpoint) RemoveOrphanedPods(remainingPods sets.Set[types.UID]) {
 | 
				
			||||||
@@ -177,7 +177,7 @@ func (sc *noopStateCheckpoint) SetPodResourceAllocation(_ types.UID, _ map[strin
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (sc *noopStateCheckpoint) Delete(_ types.UID, _ string) error {
 | 
					func (sc *noopStateCheckpoint) RemovePod(_ types.UID) error {
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,23 +79,11 @@ func (s *stateMemory) SetPodResourceAllocation(podUID types.UID, alloc map[strin
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (s *stateMemory) deleteContainer(podUID types.UID, containerName string) {
 | 
					func (s *stateMemory) RemovePod(podUID types.UID) error {
 | 
				
			||||||
	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 {
 | 
					 | 
				
			||||||
	s.Lock()
 | 
						s.Lock()
 | 
				
			||||||
	defer s.Unlock()
 | 
						defer s.Unlock()
 | 
				
			||||||
	if len(containerName) == 0 {
 | 
					 | 
				
			||||||
	delete(s.podAllocation, podUID)
 | 
						delete(s.podAllocation, podUID)
 | 
				
			||||||
		klog.V(3).InfoS("Deleted pod resource allocation and resize state", "podUID", podUID)
 | 
						klog.V(3).InfoS("Deleted pod resource allocation", "podUID", podUID)
 | 
				
			||||||
		return nil
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	s.deleteContainer(podUID, containerName)
 | 
					 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user