code: func (m *kubeGenericRuntimeManager) pruneInitContainersBeforeStart(pod *v1.Pod, podStatus *kubecontainer.PodStatus) {
  	// only the last execution of each init container should be preserved, and only preserve it if it is in the
  	// list of init containers to keep.
  	initContainerNames := sets.NewString()
  	for _, container := range pod.Spec.InitContainers {
  		initContainerNames.Insert(container.Name)
  	}
  	for name := range initContainerNames {
  		count := 0
  		for _, status := range podStatus.ContainerStatuses {
  			if status.Name != name || !initContainerNames.Has(status.Name) ||
  				(status.State != kubecontainer.ContainerStateExited &&
  					status.State != kubecontainer.ContainerStateUnknown) {
  				continue
  			}
  			// Remove init containers in unknown state. It should have
  			// been stopped before pruneInitContainersBeforeStart is
  			// called.
  			count++
  			// keep the first init container for this name
  			if count == 1 {
  				continue
  			}
  			// prune all other init containers that match this container name
  			klog.V(4).Infof("Removing init container %q instance %q %d", status.Name, status.ID.ID, count)
  			if err := m.removeContainer(status.ID.ID); err != nil {
  				utilruntime.HandleError(fmt.Errorf("failed to remove pod init container %q: %v; Skipping pod %q", status.Name, err, format.Pod(pod)))
  				continue
  			}
  
  			// remove any references to this container
  			if _, ok := m.containerRefManager.GetRef(status.ID); ok {
  				m.containerRefManager.ClearRef(status.ID)
  			} else {
  				klog.Warningf("No ref for container %q", status.ID)
  			}
  		}
  	}
  }
docs: // pruneInitContainersBeforeStart ensures that before we begin creating init
  // containers, we have reduced the number of outstanding init containers still
  // present. This reduces load on the container garbage collector by only
  // preserving the most recent terminated init container.