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 support for regional NEG stripping of maxUtilization based on url #3884

Merged
merged 3 commits into from
Aug 19, 2020

Conversation

slevenick
Copy link
Contributor

Fixes: hashicorp/terraform-provider-google#7051

If this PR is for Terraform, I acknowledge that I have:

  • Searched through the issue tracker for an open issue that this either resolves or contributes to, commented on it to claim it, and written "fixes {url}" or "part of {url}" in this PR description. If there were no relevant open issues, I opened one and commented that I would like to work on it (not necessary for very small changes).
  • Generated Terraform, and ran make test and make lint to ensure it passes unit and linter tests.
  • Ensured that all new fields I added that can be set by a user appear in at least one example (for generated resources) or third_party test (for handwritten resources or update tests).
  • Ran relevant acceptance tests (If the acceptance tests do not yet pass or you are unable to run them, please let your reviewer know).
  • Read the Release Notes Guide before writing my release note below.

Release Note Template for Downstream PRs (will be copied)

compute: Added support to `google_compute_backend_service` for setting a serverless regional network endpoint group as `backend.group`

@google-cla google-cla bot added the cla: yes label Aug 18, 2020
@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 7 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 2 files changed, 71 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 7 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140707"

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccDataSourceGoogleBigqueryDefaultServiceAccount_basic|TestAccDataSourceDnsManagedZone_basic|TestAccDataSourceDNSKeys_noDnsSec|TestAccDataSourceDNSKeys_basic|TestAccDataSourceComputeNetworkEndpointGroup|TestAccDataSourceGoogleComputeDefaultServiceAccount_basic|TestAccDataSourceComputeImage|TestAccDataSourceGoogleComputeInstanceGroup_basic|TestAccDataSourceGoogleComputeInstanceGroup_fromIGM|TestAccDataSourceGoogleComputeInstanceGroup_withNamedPort|TestAccDataSourceGoogleCloudFunctionsFunction_basic|TestAccDataSourceComputeAddress|TestAccDataSourceComputeBackendBucket_basic|TestAccDataSourceGoogleForwardingRule|TestAccDataSourceComputeBackendService_basic|TestAccDataSourceComputeNodeTypes_basic|TestAccDataSourceComputeGlobalAddress|TestAccComputeRegions_basic|TestAccComputeZones_basic|TestAccDataSourceComputeInstance_basic|TestAccDataSourceGoogleNetwork|TestAccDataSourceComputeResourcePolicy|TestAccDataSourceComputeInstanceSerialPort_basic|TestAccDataSourceComputeRouter|TestAccDataSourceComputeSslCertificate|TestAccDataSourceGoogleSubnetwork|TestAccDataSourceGoogleSslPolicy|TestAccDataSourceGoogleVpnGateway|TestAccContainerClusterDatasource_zonal|TestAccContainerClusterDatasource_regional|TestAccDataSourceGoogleStorageProjectServiceAccount_basic|TestAccBigQueryTableIamBindingGenerated|TestAccBigQueryTableIamMemberGenerated|TestAccBigQueryTableIamPolicyGenerated|TestAccBigQueryTableIamBindingGenerated_withCondition|TestAccBigQueryTableIamMemberGenerated_withCondition|TestAccBigQueryTableIamPolicyGenerated_withCondition|TestAccCloudFunctionsCloudFunctionIamBindingGenerated|TestAccCloudFunctionsCloudFunctionIamMemberGenerated|TestAccCloudFunctionsCloudFunctionIamPolicyGenerated|TestAccComputeInstanceIamBindingGenerated|TestAccComputeInstanceIamMemberGenerated|TestAccComputeInstanceIamBindingGenerated_withCondition|TestAccComputeInstanceIamPolicyGenerated|TestAccComputeInstanceIamMemberGenerated_withCondition|TestAccComputeSubnetworkIamBindingGenerated|TestAccComputeSubnetworkIamMemberGenerated|TestAccComputeSubnetworkIamBindingGenerated_withCondition|TestAccComputeInstanceIamPolicyGenerated_withCondition|TestAccComputeSubnetworkIamMemberGenerated_withCondition|TestAccComputeSubnetworkIamPolicyGenerated|TestAccComputeSubnetworkIamPolicyGenerated_withCondition|TestAccIapAppEngineVersionIamBindingGenerated|TestAccIapAppEngineVersionIamMemberGenerated|TestAccIapAppEngineVersionIamBindingGenerated_withCondition|TestAccIapAppEngineVersionIamPolicyGenerated|TestAccIapAppEngineVersionIamMemberGenerated_withCondition|TestAccIapTunnelInstanceIamBindingGenerated|TestAccIapTunnelInstanceIamMemberGenerated|TestAccIapAppEngineVersionIamPolicyGenerated_withCondition|TestAccIapTunnelInstanceIamBindingGenerated_withCondition|TestAccIapTunnelInstanceIamPolicyGenerated|TestAccIapTunnelInstanceIamMemberGenerated_withCondition|TestAccIapWebBackendServiceIamBindingGenerated|TestAccIapWebBackendServiceIamMemberGenerated|TestAccIapTunnelInstanceIamPolicyGenerated_withCondition|TestAccIapWebBackendServiceIamBindingGenerated_withCondition|TestAccIapWebBackendServiceIamMemberGenerated_withCondition|TestAccIapWebBackendServiceIamPolicyGenerated|TestAccIapWebBackendServiceIamPolicyGenerated_withCondition|TestAccIapAppEngineServiceIamMemberGenerated|TestAccIapAppEngineServiceIamBindingGenerated|TestAccIapAppEngineServiceIamBindingGenerated_withCondition|TestAccIapAppEngineServiceIamPolicyGenerated|TestAccIapAppEngineServiceIamMemberGenerated_withCondition|TestAccIapAppEngineServiceIamPolicyGenerated_withCondition|TestAccStorageBucketIamBindingGenerated|TestAccStorageBucketIamMemberGenerated|TestAccStorageBucketIamBindingGenerated_withCondition|TestAccStorageBucketIamMemberGenerated_withCondition|TestAccActiveDirectoryDomain_activeDirectoryDomainBasicExample|TestAccAppEngineApplicationUrlDispatchRules_appEngineApplicationUrlDispatchRulesBasicExample|TestAccAppEngineServiceSplitTraffic_appEngineServiceSplitTrafficExample|TestAccAppEngineStandardAppVersion_appEngineStandardAppVersionExample|TestAccBigQueryDataset_basic|TestAccBigQueryDataset_bigqueryDatasetBasicExample|TestAccBigQueryDataset_access|TestAccBigQueryDataset_datasetWithContents|TestAccBigQueryDataset_regionalLocation|TestAccBigQueryJob_bigqueryJobQueryExample|TestAccBigQueryJob_bigqueryJobQueryTableReferenceExample|TestAccBigQueryJob_bigqueryJobLoadExample|TestAccBigQueryJob_bigqueryJobLoadTableReferenceExample|TestAccBigQueryJob_bigqueryJobExtractExample|TestAccBigQueryJob_bigqueryJobExtractTableReferenceExample|TestAccBigQueryDatasetAccess_basic|TestAccBigQueryDatasetAccess_iamMember|TestAccBigQueryDatasetAccess_allUsers|TestAccBigQueryDatasetAccess_view|TestAccBigQueryDatasetAccess_allAuthenticatedUsers You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140708"

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 7 insertions(+), 2 deletions(-))
Terraform Beta: Diff ( 2 files changed, 71 insertions(+), 2 deletions(-))
TF Conversion: Diff ( 1 file changed, 7 insertions(+), 2 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140727"

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccActiveDirectoryDomain_activeDirectoryDomainBasicExample|TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample|TestAccComposerEnvironment_basic|TestAccComposerEnvironment_private|TestAccComposerEnvironment_privateWithWebServerControl|TestAccComposerEnvironment_update|TestAccComposerEnvironment_withUpdateOnCreate|TestAccComposerEnvironment_withSoftwareConfig|TestAccComputeAttachedDisk_count|TestAccComposerEnvironment_withNodeConfig|TestAccComputeBackendService_withMaxRatePerEndpoint|TestAccComputeBackendService_withMaxConnectionsPerEndpoint|TestAccComputeBackendService_regionNegBackend|TestAccComputeHealthCheck_healthCheckGrpcExample|TestAccComputeHealthCheck_healthCheckGrpcFullExample|TestAccComputeInstanceFromTemplate_basic|TestAccComputeRegionDisk_deleteDetach|TestAccComputeRegionHealthCheck_regionHealthCheckGrpcExample|TestAccComputeRegionHealthCheck_regionHealthCheckGrpcFullExample|TestAccRegionInstanceGroupManager_basic|TestAccComputeVpnGateway_targetVpnGatewayBasicExample|TestAccComputeVpnTunnel_vpnTunnelBasicExample|TestAccComputeVpnTunnel_vpnTunnelBetaExample|TestAccComputeVpnTunnel_router|TestAccComputeVpnTunnel_defaultTrafficSelectors|TestAccContainerCluster_withNodePoolNodeConfig|TestAccContainerCluster_nodeAutoprovisioning|TestAccContainerNodePool_withWorkloadIdentityConfig|TestAccMemcacheInstance_update|TestAccMemcacheInstance_memcacheInstanceBasicExample|TestAccNetworkManagementConnectivityTest_networkManagementConnectivityTestInstancesExample|TestAccNetworkManagementConnectivityTest_update|TestAccNetworkManagementConnectivityTest_networkManagementConnectivityTestAddressesExample You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140728"

if err != nil {
return nil, err
}
if match || strings.Contains(backendGroup.(string), "global/networkEndpointGroups") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels a bit extra to me to have both regex matching and strings.contains. does it make sense to do just one or the other?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, string.Contains worked for global NEGs as the key string global/networkEndpointGroups is contiguous, needed a regex to look for regions/{{region}}/networkEndpointGroups. I'll make them both use a regex

func testAccComputeBackendService_regionNegBackend(suffix string) string {
return fmt.Sprintf(`
resource "google_compute_backend_service" "backend" {
name = "backend%s"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be prefixed with tf-test so it gets swept (probably the other resources too)

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 9 insertions(+), 5 deletions(-))
Terraform Beta: Diff ( 2 files changed, 73 insertions(+), 5 deletions(-))
TF Conversion: Diff ( 1 file changed, 9 insertions(+), 5 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140958"

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample|TestAccComposerEnvironment_private|TestAccComposerEnvironment_privateWithWebServerControl|TestAccComputeBackendService_regionNegBackend|TestAccComputeHealthCheck_healthCheckGrpcExample|TestAccComputeHealthCheck_healthCheckGrpcFullExample|TestAccComputeInstanceFromTemplate_basic|TestAccComputeRegionHealthCheck_regionHealthCheckGrpcExample|TestAccComputeRegionHealthCheck_regionHealthCheckGrpcFullExample|TestAccContainerCluster_withNodePoolNodeConfig|TestAccContainerNodePool_withKubeletConfig|TestAccContainerNodePool_withInvalidKubeletCpuManagerPolicy|TestAccContainerNodePool_withLinuxNodeConfig You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140961"

// Remove `max_utilization` from any backend that belongs to a global NEG. This field
// has a default value and causes API validation errors
backend["maxUtilization"] = nil
serverlessNegMatchers := [2]*regexp.Regexp{regexp.MustCompile("projects/(?P<project>[^/]+)/regions/(?P<region>[^/]+)/networkEndpointGroups/(?P<name>[^/]+)"), regexp.MustCompile("projects/(?P<project>[^/]+)/global/networkEndpointGroups/(?P<name>[^/]+)")}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regexes only need to match part of the string, so I think just using (?:global|region/[^/]+)/networkEndpointGroups as the regex would work too and be a bit less text. any reason to do this way instead?

@modular-magician
Copy link
Collaborator

Hi! I'm the modular magician. Your PR generated some diffs in downstreams - here they are.

Diff report:

Terraform GA: Diff ( 1 file changed, 8 insertions(+), 3 deletions(-))
Terraform Beta: Diff ( 2 files changed, 72 insertions(+), 3 deletions(-))
TF Conversion: Diff ( 1 file changed, 8 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

I have triggered VCR tests based on this PR's diffs. See the results here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140962"

@modular-magician
Copy link
Collaborator

I have triggered VCR tests in RECORDING mode for the following tests that failed during VCR: TestAccActiveDirectoryDomainTrust_activeDirectoryDomainTrustBasicExample|TestAccAppEngineStandardAppVersion_update|TestAccComposerEnvironment_private|TestAccComposerEnvironment_privateWithWebServerControl|TestAccComputeInstanceFromTemplate_basic|TestAccComputeRegionHealthCheck_regionHealthCheckGrpcExample|TestAccComputeRegionHealthCheck_regionHealthCheckGrpcFullExample|TestAccContainerCluster_withNodePoolNodeConfig|TestAccContainerNodePool_withInvalidKubeletCpuManagerPolicy You can view the result here: "https://ci-oss.hashicorp.engineering/viewQueued.html?itemId=140974"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Max utilization is not supported for Serverless network endpoint groups.
3 participants