Skip to content

Commit

Permalink
Update only self updated message
Browse files Browse the repository at this point in the history
  • Loading branch information
whywaita committed Aug 1, 2022
1 parent 44dda12 commit 9979dd1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/runner/runner_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"
"time"

"github.com/google/go-github/v35/github"
Expand Down Expand Up @@ -65,14 +66,16 @@ func (m *Manager) removeRunners(ctx context.Context, t datastore.Target) error {
return fmt.Errorf("failed to check number of registerd runner: %w", err)
} else if isZero && len(runners) == 0 && mode == datastore.RunnerTemporaryOnce {
logger.Logf(false, "runner for queueing is not found in %s", t.RepoURL())
if err := datastore.UpdateTargetStatus(ctx, m.ds, t.UUID, datastore.TargetStatusErr, "runner for queueing is not found"); err != nil {
if err := datastore.UpdateTargetStatus(ctx, m.ds, t.UUID, datastore.TargetStatusErr, ErrDescriptionRunnerForQueueingIsNotFound); err != nil {
logger.Logf(false, "failed to update target status (target ID: %s): %+v\n", t.UUID, err)
}
return nil
}

if err := datastore.UpdateTargetStatus(ctx, m.ds, t.UUID, datastore.TargetStatusActive, ""); err != nil {
logger.Logf(false, "failed to update target status (target ID: %s): %+v\n", t.UUID, err)
if t.Status == datastore.TargetStatusErr && t.StatusDescription.Valid && strings.EqualFold(t.StatusDescription.String, ErrDescriptionRunnerForQueueingIsNotFound) {
if err := datastore.UpdateTargetStatus(ctx, m.ds, t.UUID, datastore.TargetStatusActive, ""); err != nil {
logger.Logf(false, "failed to update target status (target ID: %s): %+v\n", t.UUID, err)
}
}

sem := semaphore.NewWeighted(config.Config.MaxConcurrencyDeleting)
Expand Down Expand Up @@ -153,6 +156,11 @@ var (
ErrNotWillDeleteRunner = fmt.Errorf("not will delete runner")
)

const (
// ErrDescriptionRunnerForQueueingIsNotFound is error message for datastore.StatusDescription "runner for queueing is not found"
ErrDescriptionRunnerForQueueingIsNotFound = "runner for queueing is not found"
)

var (
// StatusWillDelete will delete target in GitHub runners
StatusWillDelete = "offline"
Expand Down

0 comments on commit 9979dd1

Please sign in to comment.