Skip to content

Commit 2fa6523

Browse files
Add Mirror Percent to request_mirror_policy in URLMAP (#13974) (#10071)
[upstream:3c26542473e161f238082470c8cf00560e0ac8f5] Signed-off-by: Modular Magician <[email protected]>
1 parent 37b28b2 commit 2fa6523

File tree

5 files changed

+726
-0
lines changed

5 files changed

+726
-0
lines changed

.changelog/13974.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
compute: added `mirrorPercent` field to `requestMirrorPolicy` in `defaultRouteAction`, `pathMatchers[].defaultRouteAction`, `pathMatchers[].pathRules[].routeAction`, and `pathMatchers[].routeRules[].routeAction` to `google_compute_url_map` resource (beta)
3+
```

google-beta/services/compute/resource_compute_url_map.go

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,13 @@ the host / authority header is suffixed with -shadow.`,
365365
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
366366
Description: `The full or partial URL to the BackendService resource being mirrored to.`,
367367
},
368+
"mirror_percent": {
369+
Type: schema.TypeFloat,
370+
Optional: true,
371+
ValidateFunc: validation.FloatBetween(0, 100),
372+
Description: `The percentage of requests to be mirrored to backendService.
373+
The value must be between 0.0 and 100.0 inclusive.`,
374+
},
368375
},
369376
},
370377
AtLeastOneOf: []string{"default_route_action.0.weighted_backend_services", "default_route_action.0.url_rewrite", "default_route_action.0.timeout", "default_route_action.0.retry_policy", "default_route_action.0.request_mirror_policy", "default_route_action.0.cors_policy", "default_route_action.0.fault_injection_policy"},
@@ -1092,6 +1099,13 @@ the host / authority header is suffixed with -shadow.`,
10921099
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
10931100
Description: `The full or partial URL to the BackendService resource being mirrored to.`,
10941101
},
1102+
"mirror_percent": {
1103+
Type: schema.TypeFloat,
1104+
Optional: true,
1105+
ValidateFunc: validation.FloatBetween(0, 100),
1106+
Description: `The percentage of requests to be mirrored to backendService.
1107+
The value must be between 0.0 and 100.0 inclusive.`,
1108+
},
10951109
},
10961110
},
10971111
},
@@ -1804,6 +1818,13 @@ service, the host / authority header is suffixed with -shadow.`,
18041818
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
18051819
Description: `The BackendService resource being mirrored to.`,
18061820
},
1821+
"mirror_percent": {
1822+
Type: schema.TypeFloat,
1823+
Optional: true,
1824+
ValidateFunc: validation.FloatBetween(0, 100),
1825+
Description: `The percentage of requests to be mirrored to backendService.
1826+
The value must be between 0.0 and 100.0 inclusive.`,
1827+
},
18071828
},
18081829
},
18091830
},
@@ -2753,6 +2774,13 @@ service, the host / authority header is suffixed with -shadow.`,
27532774
DiffSuppressFunc: tpgresource.CompareSelfLinkOrResourceName,
27542775
Description: `The BackendService resource being mirrored to.`,
27552776
},
2777+
"mirror_percent": {
2778+
Type: schema.TypeFloat,
2779+
Optional: true,
2780+
ValidateFunc: validation.FloatBetween(0, 100),
2781+
Description: `The percentage of requests to be mirrored to backendService.
2782+
The value must be between 0.0 and 100.0 inclusive.`,
2783+
},
27562784
},
27572785
},
27582786
},
@@ -4292,6 +4320,8 @@ func flattenComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicy(v int
42924320
transformed := make(map[string]interface{})
42934321
transformed["backend_service"] =
42944322
flattenComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyBackendService(original["backendService"], d, config)
4323+
transformed["mirror_percent"] =
4324+
flattenComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyMirrorPercent(original["mirrorPercent"], d, config)
42954325
return []interface{}{transformed}
42964326
}
42974327
func flattenComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyBackendService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -4301,6 +4331,10 @@ func flattenComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyBacken
43014331
return tpgresource.ConvertSelfLinkToV1(v.(string))
43024332
}
43034333

4334+
func flattenComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
4335+
return v
4336+
}
4337+
43044338
func flattenComputeUrlMapPathMatcherPathRuleRouteActionRetryPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
43054339
if v == nil {
43064340
return nil
@@ -5241,6 +5275,8 @@ func flattenComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicy(v i
52415275
transformed := make(map[string]interface{})
52425276
transformed["backend_service"] =
52435277
flattenComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyBackendService(original["backendService"], d, config)
5278+
transformed["mirror_percent"] =
5279+
flattenComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyMirrorPercent(original["mirrorPercent"], d, config)
52445280
return []interface{}{transformed}
52455281
}
52465282
func flattenComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyBackendService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -5250,6 +5286,10 @@ func flattenComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyBack
52505286
return tpgresource.ConvertSelfLinkToV1(v.(string))
52515287
}
52525288

5289+
func flattenComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
5290+
return v
5291+
}
5292+
52535293
func flattenComputeUrlMapPathMatcherRouteRulesRouteActionRetryPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
52545294
if v == nil {
52555295
return nil
@@ -6063,6 +6103,8 @@ func flattenComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicy(v inte
60636103
transformed := make(map[string]interface{})
60646104
transformed["backend_service"] =
60656105
flattenComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyBackendService(original["backendService"], d, config)
6106+
transformed["mirror_percent"] =
6107+
flattenComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyMirrorPercent(original["mirrorPercent"], d, config)
60666108
return []interface{}{transformed}
60676109
}
60686110
func flattenComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyBackendService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -6072,6 +6114,10 @@ func flattenComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyBackend
60726114
return tpgresource.ConvertSelfLinkToV1(v.(string))
60736115
}
60746116

6117+
func flattenComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
6118+
return v
6119+
}
6120+
60756121
func flattenComputeUrlMapPathMatcherDefaultRouteActionCorsPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
60766122
if v == nil {
60776123
return nil
@@ -6746,6 +6792,8 @@ func flattenComputeUrlMapDefaultRouteActionRequestMirrorPolicy(v interface{}, d
67466792
transformed := make(map[string]interface{})
67476793
transformed["backend_service"] =
67486794
flattenComputeUrlMapDefaultRouteActionRequestMirrorPolicyBackendService(original["backendService"], d, config)
6795+
transformed["mirror_percent"] =
6796+
flattenComputeUrlMapDefaultRouteActionRequestMirrorPolicyMirrorPercent(original["mirrorPercent"], d, config)
67496797
return []interface{}{transformed}
67506798
}
67516799
func flattenComputeUrlMapDefaultRouteActionRequestMirrorPolicyBackendService(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
@@ -6755,6 +6803,10 @@ func flattenComputeUrlMapDefaultRouteActionRequestMirrorPolicyBackendService(v i
67556803
return tpgresource.ConvertSelfLinkToV1(v.(string))
67566804
}
67576805

6806+
func flattenComputeUrlMapDefaultRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
6807+
return v
6808+
}
6809+
67586810
func flattenComputeUrlMapDefaultRouteActionCorsPolicy(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
67596811
if v == nil {
67606812
return nil
@@ -7984,6 +8036,13 @@ func expandComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicy(v inte
79848036
transformed["backendService"] = transformedBackendService
79858037
}
79868038

8039+
transformedMirrorPercent, err := expandComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyMirrorPercent(original["mirror_percent"], d, config)
8040+
if err != nil {
8041+
return nil, err
8042+
} else if val := reflect.ValueOf(transformedMirrorPercent); val.IsValid() && !tpgresource.IsEmptyValue(val) {
8043+
transformed["mirrorPercent"] = transformedMirrorPercent
8044+
}
8045+
79878046
return transformed, nil
79888047
}
79898048

@@ -8019,6 +8078,10 @@ func expandComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyBackend
80198078
return f.RelativeLink(), nil
80208079
}
80218080

8081+
func expandComputeUrlMapPathMatcherPathRuleRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
8082+
return v, nil
8083+
}
8084+
80228085
func expandComputeUrlMapPathMatcherPathRuleRouteActionRetryPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
80238086
l := v.([]interface{})
80248087
if len(l) == 0 || l[0] == nil {
@@ -9395,6 +9458,13 @@ func expandComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicy(v in
93959458
transformed["backendService"] = transformedBackendService
93969459
}
93979460

9461+
transformedMirrorPercent, err := expandComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyMirrorPercent(original["mirror_percent"], d, config)
9462+
if err != nil {
9463+
return nil, err
9464+
} else if val := reflect.ValueOf(transformedMirrorPercent); val.IsValid() && !tpgresource.IsEmptyValue(val) {
9465+
transformed["mirrorPercent"] = transformedMirrorPercent
9466+
}
9467+
93989468
return transformed, nil
93999469
}
94009470

@@ -9430,6 +9500,10 @@ func expandComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyBacke
94309500
return f.RelativeLink(), nil
94319501
}
94329502

9503+
func expandComputeUrlMapPathMatcherRouteRulesRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
9504+
return v, nil
9505+
}
9506+
94339507
func expandComputeUrlMapPathMatcherRouteRulesRouteActionRetryPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
94349508
l := v.([]interface{})
94359509
if len(l) == 0 || l[0] == nil {
@@ -10545,6 +10619,13 @@ func expandComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicy(v inter
1054510619
transformed["backendService"] = transformedBackendService
1054610620
}
1054710621

10622+
transformedMirrorPercent, err := expandComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyMirrorPercent(original["mirror_percent"], d, config)
10623+
if err != nil {
10624+
return nil, err
10625+
} else if val := reflect.ValueOf(transformedMirrorPercent); val.IsValid() && !tpgresource.IsEmptyValue(val) {
10626+
transformed["mirrorPercent"] = transformedMirrorPercent
10627+
}
10628+
1054810629
return transformed, nil
1054910630
}
1055010631

@@ -10580,6 +10661,10 @@ func expandComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyBackendS
1058010661
return f.RelativeLink(), nil
1058110662
}
1058210663

10664+
func expandComputeUrlMapPathMatcherDefaultRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
10665+
return v, nil
10666+
}
10667+
1058310668
func expandComputeUrlMapPathMatcherDefaultRouteActionCorsPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1058410669
l := v.([]interface{})
1058510670
if len(l) == 0 || l[0] == nil {
@@ -11524,6 +11609,13 @@ func expandComputeUrlMapDefaultRouteActionRequestMirrorPolicy(v interface{}, d t
1152411609
transformed["backendService"] = transformedBackendService
1152511610
}
1152611611

11612+
transformedMirrorPercent, err := expandComputeUrlMapDefaultRouteActionRequestMirrorPolicyMirrorPercent(original["mirror_percent"], d, config)
11613+
if err != nil {
11614+
return nil, err
11615+
} else if val := reflect.ValueOf(transformedMirrorPercent); val.IsValid() && !tpgresource.IsEmptyValue(val) {
11616+
transformed["mirrorPercent"] = transformedMirrorPercent
11617+
}
11618+
1152711619
return transformed, nil
1152811620
}
1152911621

@@ -11559,6 +11651,10 @@ func expandComputeUrlMapDefaultRouteActionRequestMirrorPolicyBackendService(v in
1155911651
return f.RelativeLink(), nil
1156011652
}
1156111653

11654+
func expandComputeUrlMapDefaultRouteActionRequestMirrorPolicyMirrorPercent(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
11655+
return v, nil
11656+
}
11657+
1156211658
func expandComputeUrlMapDefaultRouteActionCorsPolicy(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
1156311659
l := v.([]interface{})
1156411660
if len(l) == 0 || l[0] == nil {

google-beta/services/compute/resource_compute_url_map_generated_meta.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ fields:
2929
- field: 'default_route_action.max_stream_duration.nanos'
3030
- field: 'default_route_action.max_stream_duration.seconds'
3131
- field: 'default_route_action.request_mirror_policy.backend_service'
32+
- field: 'default_route_action.request_mirror_policy.mirror_percent'
3233
- field: 'default_route_action.retry_policy.num_retries'
3334
- field: 'default_route_action.retry_policy.per_try_timeout.nanos'
3435
- field: 'default_route_action.retry_policy.per_try_timeout.seconds'
@@ -113,6 +114,8 @@ fields:
113114
api_field: 'path_matchers.default_route_action.max_stream_duration.seconds'
114115
- field: 'path_matcher.default_route_action.request_mirror_policy.backend_service'
115116
api_field: 'path_matchers.default_route_action.request_mirror_policy.backend_service'
117+
- field: 'path_matcher.default_route_action.request_mirror_policy.mirror_percent'
118+
api_field: 'path_matchers.default_route_action.request_mirror_policy.mirror_percent'
116119
- field: 'path_matcher.default_route_action.retry_policy.num_retries'
117120
api_field: 'path_matchers.default_route_action.retry_policy.num_retries'
118121
- field: 'path_matcher.default_route_action.retry_policy.per_try_timeout.nanos'
@@ -225,6 +228,8 @@ fields:
225228
api_field: 'path_matchers.path_rules.route_action.max_stream_duration.seconds'
226229
- field: 'path_matcher.path_rule.route_action.request_mirror_policy.backend_service'
227230
api_field: 'path_matchers.path_rules.route_action.request_mirror_policy.backend_service'
231+
- field: 'path_matcher.path_rule.route_action.request_mirror_policy.mirror_percent'
232+
api_field: 'path_matchers.path_rules.route_action.request_mirror_policy.mirror_percent'
228233
- field: 'path_matcher.path_rule.route_action.retry_policy.num_retries'
229234
api_field: 'path_matchers.path_rules.route_action.retry_policy.num_retries'
230235
- field: 'path_matcher.path_rule.route_action.retry_policy.per_try_timeout.nanos'
@@ -375,6 +380,8 @@ fields:
375380
api_field: 'path_matchers.route_rules.route_action.max_stream_duration.seconds'
376381
- field: 'path_matcher.route_rules.route_action.request_mirror_policy.backend_service'
377382
api_field: 'path_matchers.route_rules.route_action.request_mirror_policy.backend_service'
383+
- field: 'path_matcher.route_rules.route_action.request_mirror_policy.mirror_percent'
384+
api_field: 'path_matchers.route_rules.route_action.request_mirror_policy.mirror_percent'
378385
- field: 'path_matcher.route_rules.route_action.retry_policy.num_retries'
379386
api_field: 'path_matchers.route_rules.route_action.retry_policy.num_retries'
380387
- field: 'path_matcher.route_rules.route_action.retry_policy.per_try_timeout.nanos'

0 commit comments

Comments
 (0)