Remove completed jobs and slight optimization

* Removes completed jobs from the db
  * Skip ensure min idle runners for pools with min idle runners set to 0

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2023-06-23 21:14:22 +00:00
parent 5153738359
commit b6a02db446

View file

@ -956,9 +956,10 @@ func (r *basePoolManager) addRunnerToPool(pool params.Pool) error {
}
func (r *basePoolManager) ensureIdleRunnersForOnePool(pool params.Pool) error {
if !pool.Enabled {
if !pool.Enabled || pool.MinIdleRunners == 0 {
return nil
}
existingInstances, err := r.store.ListPoolInstances(r.ctx, pool.ID)
if err != nil {
return fmt.Errorf("failed to ensure minimum idle workers for pool %s: %w", pool.ID, err)
@ -1514,5 +1515,9 @@ func (r *basePoolManager) consumeQueuedJobs() error {
}
}
}
if err := r.store.DeleteCompletedJobs(r.ctx); err != nil {
log.Printf("failed to delete completed jobs: %q", err)
}
return nil
}