From 43ee086360d5317aaf64562796bbfe3930763284 Mon Sep 17 00:00:00 2001 From: Sargun Dhillon Date: Mon, 19 Aug 2019 09:51:43 -0700 Subject: [PATCH] Fix mock_test DeletePod to store updated pod status --- node/mock_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/node/mock_test.go b/node/mock_test.go index fd9ad43ab..62ec97329 100644 --- a/node/mock_test.go +++ b/node/mock_test.go @@ -175,7 +175,8 @@ func (p *mockV0Provider) UpdatePod(ctx context.Context, pod *v1.Pod) error { return nil } -// DeletePod deletes the specified pod out of memory. +// DeletePod deletes the specified pod out of memory. The PodController deepcopies the pod object +// for us, so we don't have to worry about mutation. func (p *mockV0Provider) DeletePod(ctx context.Context, pod *v1.Pod) (err error) { log.G(ctx).Infof("receive DeletePod %q", pod.Name) @@ -212,8 +213,16 @@ func (p *mockV0Provider) DeletePod(ctx context.Context, pod *v1.Pod) (err error) } p.notifier(pod) - // TODO (Sargun): Eventually delete the pod from the map. We cannot right now, because GetPodStatus can / will - // be called momentarily later. + p.pods.Store(key, pod) + if pod.DeletionGracePeriodSeconds == nil || *pod.DeletionGracePeriodSeconds == 0 { + p.pods.Delete(key) + } else { + time.AfterFunc(time.Duration(*pod.DeletionGracePeriodSeconds)*time.Second, func() { + p.pods.Delete(key) + }) + + } + return nil }