Skip to content

Commit

Permalink
Lower backoff timer to 1 minute
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
  • Loading branch information
gabriel-samfira committed Jul 1, 2023
1 parent e7f1821 commit 71129a5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
6 changes: 3 additions & 3 deletions cmd/garm-cli/cmd/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ func init() {

func formatInstances(param []params.Instance) {
t := table.NewWriter()
header := table.Row{"Name", "Status", "Runner Status", "Pool ID"}
header := table.Row{"Nr", "Name", "Status", "Runner Status", "Pool ID"}
t.AppendHeader(header)

for _, inst := range param {
t.AppendRow(table.Row{inst.Name, inst.Status, inst.RunnerStatus, inst.PoolID})
for idx, inst := range param {
t.AppendRow(table.Row{idx + 1, inst.Name, inst.Status, inst.RunnerStatus, inst.PoolID})
t.AppendSeparator()
}
fmt.Println(t.Render())
Expand Down
8 changes: 3 additions & 5 deletions runner/common/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ const (
// clouds for the instance to spin up, download the tools and join gh.
PoolToolUpdateInterval = 15 * time.Minute

// UnauthorizedBackoffTimer is the time we wait before making another request
// after getting an unauthorized error from github. It is unlikely that a second
// request will not receive the same error, unless the config is changed with new
// credentials and garm is restarted.
UnauthorizedBackoffTimer = 15 * time.Minute
// BackoffTimer is the time we wait before attempting to make another request
// to the github API.
BackoffTimer = 1 * time.Minute
)

//go:generate mockery --all
Expand Down
10 changes: 4 additions & 6 deletions runner/pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (r *basePoolManager) startLoopForFunction(f func() error, interval time.Dur
// this worker was stopped.
return
default:
r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer)
r.waitForTimeoutOrCanceled(common.BackoffTimer)
}
}
}
Expand All @@ -295,18 +295,16 @@ func (r *basePoolManager) updateTools() error {
// Update tools cache.
tools, err := r.helper.FetchTools()
if err != nil {
r.log("failed to update tools for repo %s: %s", r.helper.String(), err)
r.setPoolRunningState(false, err.Error())
if errors.Is(err, runnerErrors.ErrUnauthorized) {
r.waitForTimeoutOrCanceled(common.UnauthorizedBackoffTimer)
} else {
r.waitForTimeoutOrCanceled(60 * time.Second)
}
r.waitForTimeoutOrCanceled(common.BackoffTimer)
return fmt.Errorf("failed to update tools for repo %s: %w", r.helper.String(), err)
}
r.mux.Lock()
r.tools = tools
r.mux.Unlock()

r.log("successfully updated tools")
r.setPoolRunningState(true, "")
return err
}
Expand Down

0 comments on commit 71129a5

Please sign in to comment.