Skip to content

Commit fd2192f

Browse files
Reconcile Dataproc Metastore Autoscaling Configs w/ API status (#13325) (#21877)
[upstream:5cafcdc10f44306a5c4441671b074120d91bcbf6] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 01db497 commit fd2192f

File tree

5 files changed

+390
-6
lines changed

5 files changed

+390
-6
lines changed

.changelog/13325.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
metastore: promoted `scaling_config` field to GA
3+
```

google/services/dataprocmetastore/resource_dataproc_metastore_service.go

Lines changed: 176 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,13 +325,56 @@ There must be at least one IP address available in the subnet's primary range. T
325325
MaxItems: 1,
326326
Elem: &schema.Resource{
327327
Schema: map[string]*schema.Schema{
328+
"autoscaling_config": {
329+
Type: schema.TypeList,
330+
Optional: true,
331+
Description: `Represents the autoscaling configuration of a metastore service.`,
332+
MaxItems: 1,
333+
Elem: &schema.Resource{
334+
Schema: map[string]*schema.Schema{
335+
"autoscaling_enabled": {
336+
Type: schema.TypeBool,
337+
Optional: true,
338+
Description: `Defines whether autoscaling is enabled. The default value is false.`,
339+
},
340+
"limit_config": {
341+
Type: schema.TypeList,
342+
Computed: true,
343+
Optional: true,
344+
Description: `Represents the limit configuration of a metastore service.`,
345+
MaxItems: 1,
346+
Elem: &schema.Resource{
347+
Schema: map[string]*schema.Schema{
348+
"max_scaling_factor": {
349+
Type: schema.TypeFloat,
350+
Computed: true,
351+
Optional: true,
352+
Description: `The maximum scaling factor that the service will autoscale to. The default value is 6.0.`,
353+
},
354+
"min_scaling_factor": {
355+
Type: schema.TypeFloat,
356+
Computed: true,
357+
Optional: true,
358+
Description: `The minimum scaling factor that the service will autoscale to. The default value is 0.1.`,
359+
},
360+
},
361+
},
362+
},
363+
"autoscaling_factor": {
364+
Type: schema.TypeFloat,
365+
Computed: true,
366+
Description: `Output only. The scaling factor of a service with autoscaling enabled.`,
367+
},
368+
},
369+
},
370+
},
328371
"instance_size": {
329372
Type: schema.TypeString,
330373
Optional: true,
331374
ValidateFunc: verify.ValidateEnum([]string{"EXTRA_SMALL", "SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE", ""}),
332375
Description: `Metastore instance sizes. Possible values: ["EXTRA_SMALL", "SMALL", "MEDIUM", "LARGE", "EXTRA_LARGE"]`,
333376
ConflictsWith: []string{"tier"},
334-
ExactlyOneOf: []string{"scaling_config.0.instance_size", "scaling_config.0.scaling_factor"},
377+
ExactlyOneOf: []string{"scaling_config.0.instance_size", "scaling_config.0.scaling_factor", "scaling_config.0.autoscaling_config"},
335378
},
336379
"scaling_factor": {
337380
Type: schema.TypeFloat,
@@ -1074,6 +1117,8 @@ func flattenDataprocMetastoreServiceScalingConfig(v interface{}, d *schema.Resou
10741117
flattenDataprocMetastoreServiceScalingConfigInstanceSize(original["instanceSize"], d, config)
10751118
transformed["scaling_factor"] =
10761119
flattenDataprocMetastoreServiceScalingConfigScalingFactor(original["scalingFactor"], d, config)
1120+
transformed["autoscaling_config"] =
1121+
flattenDataprocMetastoreServiceScalingConfigAutoscalingConfig(original["autoscalingConfig"], d, config)
10771122
return []interface{}{transformed}
10781123
}
10791124
func flattenDataprocMetastoreServiceScalingConfigInstanceSize(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -1084,6 +1129,54 @@ func flattenDataprocMetastoreServiceScalingConfigScalingFactor(v interface{}, d
10841129
return v
10851130
}
10861131

1132+
func flattenDataprocMetastoreServiceScalingConfigAutoscalingConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1133+
if v == nil {
1134+
return nil
1135+
}
1136+
original := v.(map[string]interface{})
1137+
if len(original) == 0 {
1138+
return nil
1139+
}
1140+
transformed := make(map[string]interface{})
1141+
transformed["autoscaling_enabled"] =
1142+
flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingEnabled(original["autoscalingEnabled"], d, config)
1143+
transformed["autoscaling_factor"] =
1144+
flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingFactor(original["autoscalingFactor"], d, config)
1145+
transformed["limit_config"] =
1146+
flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfig(original["limitConfig"], d, config)
1147+
return []interface{}{transformed}
1148+
}
1149+
func flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingEnabled(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1150+
return v
1151+
}
1152+
1153+
func flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingFactor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1154+
return v
1155+
}
1156+
1157+
func flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfig(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1158+
if v == nil {
1159+
return nil
1160+
}
1161+
original := v.(map[string]interface{})
1162+
if len(original) == 0 {
1163+
return nil
1164+
}
1165+
transformed := make(map[string]interface{})
1166+
transformed["min_scaling_factor"] =
1167+
flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMinScalingFactor(original["minScalingFactor"], d, config)
1168+
transformed["max_scaling_factor"] =
1169+
flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMaxScalingFactor(original["maxScalingFactor"], d, config)
1170+
return []interface{}{transformed}
1171+
}
1172+
func flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMinScalingFactor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1173+
return v
1174+
}
1175+
1176+
func flattenDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMaxScalingFactor(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
1177+
return v
1178+
}
1179+
10871180
func flattenDataprocMetastoreServiceScheduledBackup(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
10881181
if v == nil {
10891182
return nil
@@ -1428,6 +1521,13 @@ func expandDataprocMetastoreServiceScalingConfig(v interface{}, d tpgresource.Te
14281521
transformed["scalingFactor"] = transformedScalingFactor
14291522
}
14301523

1524+
transformedAutoscalingConfig, err := expandDataprocMetastoreServiceScalingConfigAutoscalingConfig(original["autoscaling_config"], d, config)
1525+
if err != nil {
1526+
return nil, err
1527+
} else if val := reflect.ValueOf(transformedAutoscalingConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1528+
transformed["autoscalingConfig"] = transformedAutoscalingConfig
1529+
}
1530+
14311531
return transformed, nil
14321532
}
14331533

@@ -1439,6 +1539,81 @@ func expandDataprocMetastoreServiceScalingConfigScalingFactor(v interface{}, d t
14391539
return v, nil
14401540
}
14411541

1542+
func expandDataprocMetastoreServiceScalingConfigAutoscalingConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1543+
l := v.([]interface{})
1544+
if len(l) == 0 || l[0] == nil {
1545+
return nil, nil
1546+
}
1547+
raw := l[0]
1548+
original := raw.(map[string]interface{})
1549+
transformed := make(map[string]interface{})
1550+
1551+
transformedAutoscalingEnabled, err := expandDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingEnabled(original["autoscaling_enabled"], d, config)
1552+
if err != nil {
1553+
return nil, err
1554+
} else if val := reflect.ValueOf(transformedAutoscalingEnabled); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1555+
transformed["autoscalingEnabled"] = transformedAutoscalingEnabled
1556+
}
1557+
1558+
transformedAutoscalingFactor, err := expandDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingFactor(original["autoscaling_factor"], d, config)
1559+
if err != nil {
1560+
return nil, err
1561+
} else if val := reflect.ValueOf(transformedAutoscalingFactor); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1562+
transformed["autoscalingFactor"] = transformedAutoscalingFactor
1563+
}
1564+
1565+
transformedLimitConfig, err := expandDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfig(original["limit_config"], d, config)
1566+
if err != nil {
1567+
return nil, err
1568+
} else if val := reflect.ValueOf(transformedLimitConfig); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1569+
transformed["limitConfig"] = transformedLimitConfig
1570+
}
1571+
1572+
return transformed, nil
1573+
}
1574+
1575+
func expandDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingEnabled(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1576+
return v, nil
1577+
}
1578+
1579+
func expandDataprocMetastoreServiceScalingConfigAutoscalingConfigAutoscalingFactor(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1580+
return v, nil
1581+
}
1582+
1583+
func expandDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfig(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1584+
l := v.([]interface{})
1585+
if len(l) == 0 || l[0] == nil {
1586+
return nil, nil
1587+
}
1588+
raw := l[0]
1589+
original := raw.(map[string]interface{})
1590+
transformed := make(map[string]interface{})
1591+
1592+
transformedMinScalingFactor, err := expandDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMinScalingFactor(original["min_scaling_factor"], d, config)
1593+
if err != nil {
1594+
return nil, err
1595+
} else if val := reflect.ValueOf(transformedMinScalingFactor); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1596+
transformed["minScalingFactor"] = transformedMinScalingFactor
1597+
}
1598+
1599+
transformedMaxScalingFactor, err := expandDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMaxScalingFactor(original["max_scaling_factor"], d, config)
1600+
if err != nil {
1601+
return nil, err
1602+
} else if val := reflect.ValueOf(transformedMaxScalingFactor); val.IsValid() && !tpgresource.IsEmptyValue(val) {
1603+
transformed["maxScalingFactor"] = transformedMaxScalingFactor
1604+
}
1605+
1606+
return transformed, nil
1607+
}
1608+
1609+
func expandDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMinScalingFactor(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1610+
return v, nil
1611+
}
1612+
1613+
func expandDataprocMetastoreServiceScalingConfigAutoscalingConfigLimitConfigMaxScalingFactor(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1614+
return v, nil
1615+
}
1616+
14421617
func expandDataprocMetastoreServiceScheduledBackup(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
14431618
l := v.([]interface{})
14441619
if len(l) == 0 || l[0] == nil {

google/services/dataprocmetastore/resource_dataproc_metastore_service_generated_meta.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ fields:
3333
- field: 'network_config.consumers.subnetwork'
3434
- field: 'port'
3535
- field: 'release_channel'
36+
- field: 'scaling_config.autoscaling_config.autoscaling_enabled'
37+
- field: 'scaling_config.autoscaling_config.autoscaling_factor'
38+
- field: 'scaling_config.autoscaling_config.limit_config.max_scaling_factor'
39+
- field: 'scaling_config.autoscaling_config.limit_config.min_scaling_factor'
3640
- field: 'scaling_config.instance_size'
3741
- field: 'scaling_config.scaling_factor'
3842
- field: 'scheduled_backup.backup_location'

0 commit comments

Comments
 (0)