From 87c85e6784f625f1e5b89b321432a2b7096014c7 Mon Sep 17 00:00:00 2001 From: Masayuki Ishii Date: Mon, 24 Jan 2022 04:41:26 +0000 Subject: [PATCH] Fix delete pod condition Signed-off-by: Masayuki Ishii --- controllers/runner_manager.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/controllers/runner_manager.go b/controllers/runner_manager.go index 8e2f7a2c..a0cfb36c 100644 --- a/controllers/runner_manager.go +++ b/controllers/runner_manager.go @@ -394,12 +394,13 @@ func (p *manageProcess) maintainRunnerPods(ctx context.Context, runnerList []*gi } if status.State == constants.RunnerPodStateDebugging { + needExtend := status.Extend != nil && *status.Extend && extendDuration != 0 + if needNotification && status.FinishedAt.After(lastCheckTime) { ch := slackChannel if status.SlackChannel != "" { ch = status.SlackChannel } - needExtend := *status.Extend && extendDuration != 0 err := p.slackAgentClient.PostResult(ctx, ch, status.Result, needExtend, po.Namespace, po.Name, status.JobInfo) if err != nil { log.Error(err, "failed to send a notification to slack-agent") @@ -409,10 +410,13 @@ func (p *manageProcess) maintainRunnerPods(ctx context.Context, runnerList []*gi } var needDelete bool - if status.DeletionTime == nil { - needDelete = now.After((*status.FinishedAt).Add(extendDuration)) - } else { + switch { + case status.DeletionTime != nil: needDelete = now.After(*status.DeletionTime) + case needExtend: + needDelete = now.After((*status.FinishedAt).Add(extendDuration)) + default: + needDelete = true } if needDelete { err := p.k8sClient.Delete(ctx, po)