Skip to content

Commit

Permalink
registered runner name is runner name
Browse files Browse the repository at this point in the history
  • Loading branch information
whywaita committed Dec 28, 2021
1 parent d67b287 commit 085102a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/starter/starter.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ func (s *Starter) processJob(ctx context.Context, job datastore.Job) error {
return fmt.Errorf("failed to bung (target ID: %s, job ID: %s): %w", job.TargetID, job.UUID, err)
}

runnerName := runner.ToName(job.UUID.String())
if config.Config.Strict {
if err := s.checkRegisteredRunner(ctx, cloudID, *target); err != nil {
if err := s.checkRegisteredRunner(ctx, runnerName, *target); err != nil {
logger.Logf(false, "failed to check to register runner (target ID: %s, job ID: %s): %+v\n", job.TargetID, job.UUID, err)

if err := deleteInstance(ctx, cloudID); err != nil {
Expand Down Expand Up @@ -264,7 +265,7 @@ func deleteInstance(ctx context.Context, cloudID string) error {
}

// checkRegisteredRunner check to register runner to GitHub
func (s *Starter) checkRegisteredRunner(ctx context.Context, cloudID string, target datastore.Target) error {
func (s *Starter) checkRegisteredRunner(ctx context.Context, runnerName string, target datastore.Target) error {
client, err := gh.NewClient(ctx, target.GitHubToken, target.GHEDomain.String)
if err != nil {
return fmt.Errorf("failed to create github client: %w", err)
Expand All @@ -284,15 +285,15 @@ func (s *Starter) checkRegisteredRunner(ctx context.Context, cloudID string, tar
// timeout
return fmt.Errorf("faied to to check existing runner in GitHub: timeout in %s", runner.MustRunningTime)
case <-ticker.C:
if _, err := gh.ExistGitHubRunner(cctx, client, owner, repo, cloudID); err == nil {
if _, err := gh.ExistGitHubRunner(cctx, client, owner, repo, runnerName); err == nil {
// success to register runner to GitHub
return nil
} else if !errors.Is(err, gh.ErrNotFound) {
// not retryable error
return fmt.Errorf("failed to check existing runner in GitHub: %w", err)
}
count++
logger.Logf(true, "%s is not found in GitHub, will retry... (second: %ds)", cloudID, count)
logger.Logf(true, "%s is not found in GitHub, will retry... (second: %ds)", runnerName, count)
}
}
}

0 comments on commit 085102a

Please sign in to comment.