Kubernetes executor sometimes executes after script for canceled jobs
The following discussion from !2443 (merged) should be addressed:
-
@steveazz started a discussion: (+5 comments) @ayufan @ajwalker it's time to merge this
❤ 🚀 🎊 Thank you both for the hard work on this, I know it took a really long time to get here but we finally did it
🚀
The patch below seems to fix it
diff --git a/executors/kubernetes/kubernetes.go b/executors/kubernetes/kubernetes.go
index 6956efff6..0aedb5d2c 100644
--- a/executors/kubernetes/kubernetes.go
+++ b/executors/kubernetes/kubernetes.go
@@ -222,7 +222,7 @@ func (s *executor) runWithAttach(cmd common.ExecutorCommand) error {
return err
}
- ctx, cancel := context.WithCancel(cmd.Context)
+ ctx, cancel := context.WithCancel(s.Context)
defer cancel()
containerName := buildContainerName
Edited by Steve Xuereb