Skip to content

Commit 9726043

Browse files
bigqueryreservation: added support for scaling_mode and max_slots properties on google_bigquery_reservation (beta) (#14056)
1 parent f8458f0 commit 9726043

2 files changed

Lines changed: 174 additions & 0 deletions

File tree

mmv1/products/bigqueryreservation/Reservation.yaml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,100 @@ properties:
156156
replicated to the secondary.
157157
output: true
158158
output: true
159+
- name: 'scalingMode'
160+
type: Enum
161+
min_version: beta
162+
description: |
163+
The scaling mode for the reservation. If the field is present but maxSlots is not present,
164+
requests will be rejected with error code google.rpc.Code.INVALID_ARGUMENT.
165+
166+
Enum values:
167+
168+
`SCALING_MODE_UNSPECIFIED`: Default value of ScalingMode.
169+
170+
`AUTOSCALE_ONLY`: The reservation will scale up only using slots from autoscaling. It will
171+
not use any idle slots even if there may be some available. The upper limit that autoscaling
172+
can scale up to will be maxSlots - baseline. For example, if maxSlots is 1000, baseline is 200
173+
and customer sets ScalingMode to AUTOSCALE_ONLY, then autoscalerg will scale up to 800 slots
174+
and no idle slots will be used. Please note, in this mode, the ignoreIdleSlots field must be
175+
set to true. Otherwise the request will be rejected with error code
176+
google.rpc.Code.INVALID_ARGUMENT.
177+
178+
`IDLE_SLOTS_ONLY`: The reservation will scale up using only idle slots contributed by other
179+
reservations or from unassigned commitments. If no idle slots are available it will not scale
180+
up further. If the idle slots which it is using are reclaimed by the contributing reservation(s)
181+
it may be forced to scale down. The max idle slots the reservation can be maxSlots - baseline
182+
capacity. For example, if maxSlots is 1000, baseline is 200 and customer sets ScalingMode to
183+
IDLE_SLOTS_ONLY, 1. if there are 1000 idle slots available in other reservations, the
184+
reservation will scale up to 1000 slots with 200 baseline and 800 idle slots. 2. if there are
185+
500 idle slots available in other reservations, the reservation will scale up to 700 slots with
186+
200 baseline and 300 idle slots. Please note, in this mode, the reservation might not be able to
187+
scale up to maxSlots. Please note, in this mode, the ignoreIdleSlots field must be set to false.
188+
Otherwise the request will be rejected with error code google.rpc.Code.INVALID_ARGUMENT
189+
190+
`ALL_SLOTS`: The reservation will scale up using all slots available to it. It will use idle slots
191+
contributed by other reservations or from unassigned commitments first. If no idle slots are
192+
available it will scale up using autoscaling. For example, if maxSlots is 1000, baseline is 200
193+
and customer sets ScalingMode to ALL_SLOTS, 1. if there are 800 idle slots available in other
194+
reservations, the reservation will scale up to 1000 slots with 200 baseline and 800 idle slots. 2.
195+
if there are 500 idle slots available in other reservations, the reservation will scale up to 1000
196+
slots with 200 baseline, 500 idle slots and 300 autoscaling slots. 3. if there are no idle slots
197+
available in other reservations, it will scale up to 1000 slots with 200 baseline and 800
198+
autoscaling slots. Please note, in this mode, the ignoreIdleSlots field must be set to false.
199+
Otherwise the request will be rejected with error code google.rpc.Code.INVALID_ARGUMENT.
200+
enum_values:
201+
- 'SCALING_MODE_UNSPECIFIED'
202+
- 'AUTOSCALE_ONLY'
203+
- 'IDLE_SLOTS_ONLY'
204+
- 'ALL_SLOTS'
205+
required_with:
206+
- 'maxSlots'
207+
conflicts:
208+
- 'autoscale'
209+
- name: 'maxSlots'
210+
type: Integer
211+
min_version: beta
212+
description: |
213+
The overall max slots for the reservation, covering slotCapacity (baseline), idle slots
214+
(if ignoreIdleSlots is false) and scaled slots. If present, the reservation won't use
215+
more than the specified number of slots, even if there is demand and supply (from idle
216+
slots). NOTE: capping a reservation's idle slot usage is best effort and its usage may
217+
exceed the maxSlots value. However, in terms of autoscale.current_slots (which accounts
218+
for the additional added slots), it will never exceed the maxSlots - baseline.
219+
220+
This field must be set together with the scalingMode enum value, otherwise the request
221+
will be rejected with error code google.rpc.Code.INVALID_ARGUMENT.
222+
223+
If the maxSlots and scalingMode are set, the autoscale or autoscale.max_slots field
224+
must be unset. Otherwise the request will be rejected with error code
225+
google.rpc.Code.INVALID_ARGUMENT. However, the autoscale field may still be in the
226+
output. The autopscale.max_slots will always show as 0 and the autoscaler.current_slots
227+
will represent the current slots from autoscaler excluding idle slots. For example,
228+
if the maxSlots is 1000 and scalingMode is AUTOSCALE_ONLY, then in the output, the
229+
autoscaler.max_slots will be 0 and the autoscaler.current_slots may be any value
230+
between 0 and 1000.
231+
232+
If the maxSlots is 1000, scalingMode is ALL_SLOTS, the baseline is 100 and idle slots
233+
usage is 200, then in the output, the autoscaler.max_slots will be 0 and the
234+
autoscaler.current_slots will not be higher than 700.
235+
236+
If the maxSlots is 1000, scalingMode is IDLE_SLOTS_ONLY, then in the output, the
237+
autoscaler field will be null.
238+
239+
If the maxSlots and scalingMode are set, then the ignoreIdleSlots field must be
240+
aligned with the scalingMode enum value.(See details in ScalingMode comments).
241+
Otherwise the request will be rejected with error code google.rpc.Code.INVALID_ARGUMENT.
242+
243+
Please note, the maxSlots is for user to manage the part of slots greater than the
244+
baseline. Therefore, we don't allow users to set maxSlots smaller or equal to the
245+
baseline as it will not be meaningful. If the field is present and
246+
slotCapacity>=maxSlots, requests will be rejected with error code
247+
google.rpc.Code.INVALID_ARGUMENT.
248+
249+
Please note that if maxSlots is set to 0, we will treat it as unset. Customers can set
250+
maxSlots to 0 and set scalingMode to SCALING_MODE_UNSPECIFIED to disable the maxSlots
251+
feature.
252+
required_with:
253+
- 'scalingMode'
254+
conflicts:
255+
- 'autoscale'

mmv1/third_party/terraform/services/bigqueryreservation/resource_bigquery_reservation_test.go renamed to mmv1/third_party/terraform/services/bigqueryreservation/resource_bigquery_reservation_test.go.tmpl

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,41 @@ func TestAccBigqueryReservation_withDisasterRecovery_update(t *testing.T) {
3838
})
3939
}
4040

41+
{{ if ne $.TargetVersionName `ga` -}}
42+
43+
func TestAccBigqueryReservation_withScalingMode_update(t *testing.T) {
44+
t.Parallel()
45+
46+
context := map[string]interface{}{
47+
"random_suffix": acctest.RandString(t, 10),
48+
}
49+
50+
acctest.VcrTest(t, resource.TestCase{
51+
PreCheck: func() { acctest.AccTestPreCheck(t) },
52+
ProtoV5ProviderFactories: acctest.ProtoV5ProviderBetaFactories(t),
53+
Steps: []resource.TestStep{
54+
{
55+
Config: testAccBigqueryReservation_withScalingMode_basic(context),
56+
},
57+
{
58+
ResourceName: "google_bigquery_reservation.reservation",
59+
ImportState: true,
60+
ImportStateVerify: true,
61+
},
62+
{
63+
Config: testAccBigqueryReservation_withScalingMode_update(context),
64+
},
65+
{
66+
ResourceName: "google_bigquery_reservation.reservation",
67+
ImportState: true,
68+
ImportStateVerify: true,
69+
},
70+
},
71+
})
72+
}
73+
74+
{{ end }}
75+
4176
func testAccBigqueryReservation_withDisasterRecovery_basic(context map[string]interface{}) string {
4277
return acctest.Nprintf(`
4378
resource "google_bigquery_reservation" "reservation" {
@@ -78,3 +113,45 @@ resource "google_bigquery_reservation" "reservation" {
78113
}
79114
`, context)
80115
}
116+
117+
{{ if ne $.TargetVersionName `ga` -}}
118+
119+
func testAccBigqueryReservation_withScalingMode_basic(context map[string]interface{}) string {
120+
return acctest.Nprintf(`
121+
resource "google_bigquery_reservation" "reservation" {
122+
provider = google-beta
123+
name = "tf-test-reservation-%{random_suffix}"
124+
location = "us-west2"
125+
126+
// Set to 0 for testing purposes
127+
// In reality this would be larger than zero
128+
slot_capacity = 0
129+
edition = "ENTERPRISE_PLUS"
130+
ignore_idle_slots = true
131+
concurrency = 0
132+
max_slots = 100
133+
scaling_mode = "AUTOSCALE_ONLY"
134+
}
135+
`, context)
136+
}
137+
138+
func testAccBigqueryReservation_withScalingMode_update(context map[string]interface{}) string {
139+
return acctest.Nprintf(`
140+
resource "google_bigquery_reservation" "reservation" {
141+
provider = google-beta
142+
name = "tf-test-reservation-%{random_suffix}"
143+
location = "us-west2"
144+
145+
// Set to 0 for testing purposes
146+
// In reality this would be larger than zero
147+
slot_capacity = 0
148+
edition = "ENTERPRISE_PLUS"
149+
ignore_idle_slots = false
150+
concurrency = 0
151+
max_slots = 50
152+
scaling_mode = "ALL_SLOTS"
153+
}
154+
`, context)
155+
}
156+
157+
{{ end }}

0 commit comments

Comments
 (0)