mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-27 13:15:36 +00:00
Fix secret/configmap management for terminated pods
This commit is contained in:
@@ -168,20 +168,40 @@ func (pm *basicManager) UpdatePod(pod *v1.Pod) {
|
||||
}
|
||||
}
|
||||
|
||||
func isPodInTerminatedState(pod *v1.Pod) bool {
|
||||
return pod.Status.Phase == v1.PodFailed || pod.Status.Phase == v1.PodSucceeded
|
||||
}
|
||||
|
||||
// updatePodsInternal replaces the given pods in the current state of the
|
||||
// manager, updating the various indices. The caller is assumed to hold the
|
||||
// lock.
|
||||
func (pm *basicManager) updatePodsInternal(pods ...*v1.Pod) {
|
||||
for _, pod := range pods {
|
||||
if pm.secretManager != nil {
|
||||
// TODO: Consider detecting only status update and in such case do
|
||||
// not register pod, as it doesn't really matter.
|
||||
pm.secretManager.RegisterPod(pod)
|
||||
if isPodInTerminatedState(pod) {
|
||||
// Pods that are in terminated state and no longer running can be
|
||||
// ignored as they no longer require access to secrets.
|
||||
// It is especially important in watch-based manager, to avoid
|
||||
// unnecessary watches for terminated pods waiting for GC.
|
||||
pm.secretManager.UnregisterPod(pod)
|
||||
} else {
|
||||
// TODO: Consider detecting only status update and in such case do
|
||||
// not register pod, as it doesn't really matter.
|
||||
pm.secretManager.RegisterPod(pod)
|
||||
}
|
||||
}
|
||||
if pm.configMapManager != nil {
|
||||
// TODO: Consider detecting only status update and in such case do
|
||||
// not register pod, as it doesn't really matter.
|
||||
pm.configMapManager.RegisterPod(pod)
|
||||
if isPodInTerminatedState(pod) {
|
||||
// Pods that are in terminated state and no longer running can be
|
||||
// ignored as they no longer require access to configmaps.
|
||||
// It is especially important in watch-based manager, to avoid
|
||||
// unnecessary watches for terminated pods waiting for GC.
|
||||
pm.configMapManager.UnregisterPod(pod)
|
||||
} else {
|
||||
// TODO: Consider detecting only status update and in such case do
|
||||
// not register pod, as it doesn't really matter.
|
||||
pm.configMapManager.RegisterPod(pod)
|
||||
}
|
||||
}
|
||||
podFullName := kubecontainer.GetPodFullName(pod)
|
||||
// This logic relies on a static pod and its mirror to have the same name.
|
||||
|
Reference in New Issue
Block a user