Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add future limit to quota exceeded error #15346

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/8484.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
compute: add future_limit in quota exceeded error details for compute resources.
```
7 changes: 7 additions & 0 deletions google/services/compute/compute_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ func writeOperationError(w io.StringWriter, opError *compute.OperationErrorError
if opError.Code == "QUOTA_EXCEEDED" && ed.QuotaInfo != nil {
w.WriteString("\tmetric name = " + ed.QuotaInfo.MetricName + "\n")
w.WriteString("\tlimit name = " + ed.QuotaInfo.LimitName + "\n")
if ed.QuotaInfo.Limit != 0 {
w.WriteString("\tlimit = " + fmt.Sprint(ed.QuotaInfo.Limit) + "\n")
}
if ed.QuotaInfo.FutureLimit != 0 {
w.WriteString("\tfuture limit = " + fmt.Sprint(ed.QuotaInfo.FutureLimit) + "\n")
w.WriteString("\trollout status = in progress\n")
}
if ed.QuotaInfo.Dimensions != nil {
w.WriteString("\tdimensions = " + fmt.Sprint(ed.QuotaInfo.Dimensions) + "\n")
}
Expand Down
49 changes: 45 additions & 4 deletions google/services/compute/compute_operation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func buildOperationError(numLocalizedMsg int, numHelpWithLinks []int) compute.Op

}

func buildOperationErrorQuotaExceeded(withDetails bool, withDimensions bool) compute.OperationError {
func buildOperationErrorQuotaExceeded(withDetails bool, withDimensions bool, withFutureLimit bool) compute.OperationError {
opError := &compute.OperationErrorErrors{Message: quotaExceededMsg, Code: quotaExceededCode}
opErrorErrors := []*compute.OperationErrorErrors{opError}
if withDetails {
Expand All @@ -66,6 +66,9 @@ func buildOperationErrorQuotaExceeded(withDetails bool, withDimensions bool) com
LimitName: quotaLimitName,
Limit: 1100,
}
if withFutureLimit {
quotaInfo.FutureLimit = 2200
}
if withDimensions {
quotaInfo.Dimensions = map[string]string{"region": "us-central1"}
}
Expand Down Expand Up @@ -207,33 +210,71 @@ func TestComputeOperationError_Error(t *testing.T) {
},
{
name: "QuotaMessageOnly",
input: buildOperationErrorQuotaExceeded(false, false),
input: buildOperationErrorQuotaExceeded(false, false, false),
expectContains: []string{
"Quota DISKS_TOTAL_GB exceeded. Limit: 1100.0 in region us-central1.",
},
expectOmits: append(omitAlways(0, []int{}), []string{
"metric name = compute.googleapis.com/disks_total_storage",
"limit = 1100",
}...),
},
{
name: "QuotaMessageWithDetailsNoDimensions",
input: buildOperationErrorQuotaExceeded(true, false),
input: buildOperationErrorQuotaExceeded(true, false, false),
expectContains: []string{
"Quota DISKS_TOTAL_GB exceeded. Limit: 1100.0 in region us-central1.",
"metric name = compute.googleapis.com/disks_total_storage",
"limit name = DISKS-TOTAL-GB-per-project-region",
"limit = 1100",
},
expectOmits: append(omitAlways(0, []int{}), []string{
"dimensions = map[region:us-central1]",
}...),
},
{
name: "QuotaMessageWithDetailsWithDimensions",
input: buildOperationErrorQuotaExceeded(true, true),
input: buildOperationErrorQuotaExceeded(true, true, false),
expectContains: []string{
"Quota DISKS_TOTAL_GB exceeded. Limit: 1100.0 in region us-central1.",
"metric name = compute.googleapis.com/disks_total_storage",
"limit name = DISKS-TOTAL-GB-per-project-region",
"limit = 1100",
"dimensions = map[region:us-central1]",
},
expectOmits: append(omitAlways(0, []int{}), []string{
"LocalizedMessage1",
"Help1Link1 Description",
"https://help1.com/link1",
}...),
},
{
name: "QuotaMessageWithDetailsWithFutureLimit",
input: buildOperationErrorQuotaExceeded(true, false, true),
expectContains: []string{
"Quota DISKS_TOTAL_GB exceeded. Limit: 1100.0 in region us-central1.",
"metric name = compute.googleapis.com/disks_total_storage",
"limit name = DISKS-TOTAL-GB-per-project-region",
"limit = 1100",
"future limit = 2200",
"rollout status = in progress",
},
expectOmits: append(omitAlways(0, []int{}), []string{
"LocalizedMessage1",
"Help1Link1 Description",
"https://help1.com/link1",
}...),
},
{
name: "QuotaMessageWithDetailsWithDimensionsWithFutureLimit",
input: buildOperationErrorQuotaExceeded(true, true, true),
expectContains: []string{
"Quota DISKS_TOTAL_GB exceeded. Limit: 1100.0 in region us-central1.",
"metric name = compute.googleapis.com/disks_total_storage",
"limit name = DISKS-TOTAL-GB-per-project-region",
"limit = 1100",
"future limit = 2200",
"rollout status = in progress",
"dimensions = map[region:us-central1]",
},
expectOmits: append(omitAlways(0, []int{}), []string{
Expand Down