Lower backoff timer to 1 minute

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-06-30 10:15:22 +00:00
parent 7f510ec40a
commit f92ac2a74f
3 changed files with 10 additions and 14 deletions

View file

@ -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())

View file

@ -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

View file

@ -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)
}
}
}
@ -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
}