Optimize orphan cleanup and add Debian to OS list

* Runner names are unique. Skip querying pool, then runner name. Just fetch
the runner, which has a PoolID field set that can be used to determine the
pool.
  * Add Debian to the list of Linux OSs
This commit is contained in:
Gabriel Adrian Samfira 2022-06-24 09:59:55 +00:00
parent 808bc42d33
commit 63824247be
2 changed files with 7 additions and 18 deletions

View file

@ -536,25 +536,8 @@ func (r *basePool) cleanupOrphanedGithubRunners(runners []*github.Runner) error
}
removeRunner := false
poolID, err := r.poolIDFromLabels(runner.Labels)
if err != nil {
if !errors.Is(err, runnerErrors.ErrNotFound) {
return errors.Wrap(err, "finding pool")
}
// not a runner we manage
continue
}
pool, err := r.helper.GetPoolByID(poolID)
if err != nil {
if !errors.Is(err, runnerErrors.ErrNotFound) {
return errors.Wrap(err, "fetching pool")
}
// not pool we manage.
continue
}
dbInstance, err := r.store.GetPoolInstanceByName(r.ctx, poolID, *runner.Name)
dbInstance, err := r.store.GetInstanceByName(r.ctx, *runner.Name)
if err != nil {
if !errors.Is(err, runnerErrors.ErrNotFound) {
return errors.Wrap(err, "fetching instance from DB")
@ -563,6 +546,11 @@ func (r *basePool) cleanupOrphanedGithubRunners(runners []*github.Runner) error
// removal may have failed?
removeRunner = true
} else {
pool, err := r.helper.GetPoolByID(dbInstance.PoolID)
if err != nil {
return errors.Wrap(err, "fetching pool")
}
if providerCommon.InstanceStatus(dbInstance.Status) == providerCommon.InstancePendingDelete {
// already marked for deleting. Let consolidate take care of it.
continue

View file

@ -61,6 +61,7 @@ var (
"centos": config.Linux,
"suse": config.Linux,
"fedora": config.Linux,
"debian": config.Linux,
"flatcar": config.Linux,
"gentoo": config.Linux,
"windows": config.Windows,