From 543ca876b27d90cb906ddb2643112a62dc923f56 Mon Sep 17 00:00:00 2001 From: Florian Bacher Date: Wed, 12 Oct 2022 10:46:16 +0200 Subject: [PATCH] fix(scheduler): Create new context when starting background routine for pod checks (#148) Signed-off-by: Florian Bacher --- scheduler/pkg/klcpermit/permit.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scheduler/pkg/klcpermit/permit.go b/scheduler/pkg/klcpermit/permit.go index a6585479da..c8348b1950 100644 --- a/scheduler/pkg/klcpermit/permit.go +++ b/scheduler/pkg/klcpermit/permit.go @@ -45,7 +45,12 @@ func (pl *Permit) Permit(ctx context.Context, state *framework.CycleState, p *v1 return framework.NewStatus(framework.Success), 0 * time.Second default: klog.Infof("[Keptn Permit Plugin] waiting for pre-deployment checks on %s", p.GetObjectMeta().GetName()) - go pl.monitorPod(ctx, p) + go func() { + // create a new context since we are in a new goroutine + ctx2, cancel := context.WithCancel(context.Background()) + defer cancel() + pl.monitorPod(ctx2, p) + }() return framework.NewStatus(framework.Wait), 5 * time.Minute }