Skip to content

Commit

Permalink
Merge pull request #3916 from abhinavdahiya/gcp_quota_check
Browse files Browse the repository at this point in the history
asset/quota: warn and skip when all quota errors are type unknown
  • Loading branch information
openshift-merge-robot committed Jul 18, 2020
2 parents 9871d47 + 206717b commit 84cb23d
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions pkg/asset/quota/quota.go
Expand Up @@ -119,21 +119,31 @@ func (a *PlatformQuotaCheck) Name() string {
}

// summarizeFailingReport summarizes a report when there are failing constraints.
func summarizeFailingReport(reports []quota.ConstraintReport) *diagnostics.Err {
dErr := &diagnostics.Err{Reason: "MissingQuota"}
var messages []string
func summarizeFailingReport(reports []quota.ConstraintReport) error {
var notavailable []string
var unknown []string
for _, report := range reports {
switch report.Result {
case quota.NotAvailable:
messages = append(messages, fmt.Sprintf("%s is not available in %s because %s", report.For.Name, report.For.Region, report.Message))
notavailable = append(notavailable, fmt.Sprintf("%s is not available in %s because %s", report.For.Name, report.For.Region, report.Message))
case quota.Unknown:
messages = append(messages, fmt.Sprintf("could not find any quota information for %s", report.For.Name))
unknown = append(unknown, report.For.Name)
default:
continue
}
}
dErr.Message = strings.Join(messages, ", ")
return dErr

if len(notavailable) == 0 && len(unknown) > 0 {
// all quotas are missing information so warn and skip
logrus.Warnf("Failed to find information on quotas %s", strings.Join(unknown, ", "))
return nil
}

msg := strings.Join(notavailable, ", ")
if len(unknown) > 0 {
msg = fmt.Sprintf("%s, and could not find information on %s", msg, strings.Join(unknown, ", "))
}
return &diagnostics.Err{Reason: "MissingQuota", Message: msg}
}

// summarizeReport summarizes a report when there are availble.
Expand Down

0 comments on commit 84cb23d

Please sign in to comment.