Skip to content

Commit

Permalink
Fix delete pod condition
Browse files Browse the repository at this point in the history
Signed-off-by: Masayuki Ishii <[email protected]>
  • Loading branch information
masa213f committed Jan 24, 2022
1 parent 8802c29 commit 87c85e6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions controllers/runner_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down

0 comments on commit 87c85e6

Please sign in to comment.