Skip to content

Commit

Permalink
Merge pull request #134 from cybozu-go/fix-delete-condition
Browse files Browse the repository at this point in the history
Fix delete pod condition
  • Loading branch information
masa213f authored Jan 25, 2022
2 parents 8802c29 + 87c85e6 commit 0ae6ce2
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 0ae6ce2

Please sign in to comment.