in step_wait_for_quota.go [77:110]
func (aq *WaitForAvailableQuotas) run(ctx context.Context, s *Step) DError {
for _, a := range aq.Quotas {
s.w.LogStepInfo(s.name, "WaitForAvailableQuotas", "Waiting for %.2f units of %s to be available in %s", a.Units, a.Metric, a.Region)
}
tick := time.Tick(aq.parsedInterval)
for {
select {
case <-s.w.Cancel:
return nil
case <-ctx.Done():
err := fmt.Errorf("context expired before quota was available in step %s", s.name)
return typedErr(ctx.Err().Error(), err.Error(), err)
case <-tick:
var successmsgs []string
for _, a := range aq.Quotas {
r, err := s.w.ComputeClient.GetRegion(s.w.Project, a.Region)
if err != nil {
return typedErr(apiError, "failed to get region "+a.Region, err)
}
for _, q := range r.Quotas {
if q.Metric == a.Metric && ((q.Limit - q.Usage) >= a.Units) {
successmsgs = append(successmsgs, fmt.Sprintf("Region %s has %.2f units of %s available", a.Region, (q.Limit-q.Usage), a.Metric))
}
}
}
if len(successmsgs) == len(aq.Quotas) {
for _, m := range successmsgs {
s.w.LogStepInfo(s.name, "WaitForAvailableQuotas", m)
}
return nil
}
}
}
}