Remove some blocking code

* added 2 new statuses: creating and deleting
  * remove wait on create/delete, speeding things up a bit
This commit is contained in:
Gabriel Adrian Samfira 2022-05-13 23:34:16 +00:00
parent e7eb13acc9
commit 98eb594cd6
4 changed files with 86 additions and 63 deletions

View file

@ -230,3 +230,17 @@ func (s *sqlDatabase) ListAllInstances(ctx context.Context) ([]params.Instance,
}
return ret, nil
}
func (s *sqlDatabase) PoolInstanceCount(ctx context.Context, poolID string) (int64, error) {
pool, err := s.getPoolByID(ctx, poolID)
if err != nil {
return 0, errors.Wrap(err, "fetching pool")
}
var cnt int64
q := s.conn.Model(&Instance{}).Where("pool_id = ?", pool.ID).Count(&cnt)
if q.Error != nil {
return 0, errors.Wrap(q.Error, "fetching instance count")
}
return cnt, nil
}