mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Merge pull request #48322 from k82cn/k8s_47867
Automatic merge from submit-queue (batch tested with PRs 48402, 47203, 47460, 48335, 48322) Added case on 'terminated-but-not-yet-deleted' for Admit. **What this PR does / why we need it**: Added case on 'terminated-but-not-yet-deleted' for Admit. **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #47867 **Release note**: ```release-note-none ```
This commit is contained in:
commit
d68e7378f4
@ -729,9 +729,8 @@ func (kl *Kubelet) getPullSecretsForPod(pod *v1.Pod) []v1.Secret {
|
||||
return pullSecrets
|
||||
}
|
||||
|
||||
// Returns true if pod is in the terminated state ("Failed" or "Succeeded").
|
||||
// podIsTerminated returns true if pod is in the terminated state ("Failed" or "Succeeded").
|
||||
func (kl *Kubelet) podIsTerminated(pod *v1.Pod) bool {
|
||||
var status v1.PodStatus
|
||||
// Check the cached pod status which was set after the last sync.
|
||||
status, ok := kl.statusManager.GetPodStatus(pod.UID)
|
||||
if !ok {
|
||||
|
@ -1249,10 +1249,21 @@ func TestFilterOutTerminatedPods(t *testing.T) {
|
||||
defer testKubelet.Cleanup()
|
||||
kubelet := testKubelet.kubelet
|
||||
pods := newTestPods(5)
|
||||
now := metav1.NewTime(time.Now())
|
||||
pods[0].Status.Phase = v1.PodFailed
|
||||
pods[1].Status.Phase = v1.PodSucceeded
|
||||
// The pod is terminating, should not filter out.
|
||||
pods[2].Status.Phase = v1.PodRunning
|
||||
pods[2].DeletionTimestamp = &now
|
||||
pods[2].Status.ContainerStatuses = []v1.ContainerStatus{
|
||||
{State: v1.ContainerState{
|
||||
Running: &v1.ContainerStateRunning{
|
||||
StartedAt: now,
|
||||
},
|
||||
}},
|
||||
}
|
||||
pods[3].Status.Phase = v1.PodPending
|
||||
pods[4].Status.Phase = v1.PodRunning
|
||||
|
||||
expected := []*v1.Pod{pods[2], pods[3], pods[4]}
|
||||
kubelet.podManager.SetPods(pods)
|
||||
|
Loading…
Reference in New Issue
Block a user