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

feat(google_container_cluster): allow enabling cost allocation #6469

Merged

Conversation

renescheepers
Copy link
Contributor

@renescheepers renescheepers commented Aug 25, 2022

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)

container: Added general field `enable_cost_allocation` to `google_container_cluster`

Description

https://cloud.google.com/kubernetes-engine/docs/how-to/cost-allocations#update_cluster

resource "google_container_cluster" "primary" {
  provider = google-beta

  name     = "cluster-4"
  location = "us-east1"

  remove_default_node_pool = true
  initial_node_count       = 1

  cost_management_config {
    enabled = true
  }
}

Fixes hashicorp/terraform-provider-google#12391

@google-cla
Copy link

google-cla bot commented Aug 25, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@modular-magician
Copy link
Collaborator

Oops! It looks like you're using an unknown release-note type in your changelog entries:

  • REPLACEME

Please only use the types listed in https://github.com/GoogleCloudPlatform/magic-modules/blob/master/.ci/RELEASE_NOTES_GUIDE.md.

@modular-magician
Copy link
Collaborator

Hello! I am a robot who works on Magic Modules PRs.

I've detected that you're a community contributor. @c2thorn, a repository maintainer, has been assigned to assist you and help review your changes.

❓ First time contributing? Click here for more details

Your assigned reviewer will help review your code by:

  • Ensuring it's backwards compatible, covers common error cases, etc.
  • Summarizing the change into a user-facing changelog note.
  • Passes tests, either our "VCR" suite, a set of presubmit tests, or with manual test runs.

You can help make sure that review is quick by running local tests and ensuring they're passing in between each push you make to your PR's branch. Also, try to leave a comment with each push you make, as pushes generally don't generate emails.

If your reviewer doesn't get back to you within a week after your most recent change, please feel free to leave a comment on the issue asking them to take a look! In the absence of a dedicated review dashboard most maintainers manage their pending reviews through email, and those will sometimes get lost in their inbox.


@modular-magician
Copy link
Collaborator

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

Diff report:

Terraform Beta: Diff ( 1 file changed, 34 insertions(+))

Copy link
Member

@c2thorn c2thorn left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @renescheepers. I understand this is still in draft mode, but I have some immediate feedback to share just in case it shortens the feedback loop time.

Aside from individual comments, it will be necessary to either add a test that uses this field, or add the field to an existing test. Also, it will need to be added to documentation file.

@@ -1466,6 +1466,15 @@ func resourceContainerCluster() *schema.Resource {
Computed: true,
},

<% if version == 'beta' -%>
"enable_cost_allocation": {
Copy link
Member

Choose a reason for hiding this comment

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

Haven't looked at the API documentation yet, but it looks like the API defines this as CostManagementConfig.Enabled. We have shied away from flattening fields like this recently because if the API adds more fields later, it becomes a breaking change to correct. For an example of a similar field, I think mesh_certificates.enable_certificates.

My recommendation is to expand the field to cost_management_config.enabled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, wasn't sure which structure to pick since I saw both being used. Should now be fixed.

Comment on lines 1678 to 1679
<% end -%>
<% if version == 'beta' -%>
Copy link
Member

Choose a reason for hiding this comment

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

<% unless version == 'ga' -%> is the same as <% if version == 'beta' -%>, just weird ruby-isms. We can save a couple of lines throughout the file by merging the two statements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to <% unless version == 'ga' -%> everywhere in this file.

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2144
Passed tests 1787
Skipped tests: 230
Failed tests: 127

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccSqlDatabaseInstance_SqlServerAuditConfig|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange|TestAccIapTunnelIamBindingGenerated|TestAccGKEHubMembershipIamPolicyGenerated|TestAccGKEHubMembershipIamMemberGenerated|TestAccGKEHubMembershipIamBindingGenerated|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample|TestAccContainerNodePool_withUpgradeSettings|TestAccContainerNodePool_withNetworkConfig|TestAccContainerCluster_withBinaryAuthorizationEnabledBoolLegacy|TestAccContainerCluster_withShieldedNodes|TestAccContainerNodePool_withLinuxNodeConfig|TestAccContainerNodePool_withKubeletConfig|TestAccContainerCluster_withBinaryAuthorizationEnabledBool|TestAccContainerNodePool_withSandboxConfig|TestAccContainerCluster_withAutoscalingProfile|TestAccContainerCluster_withAuthenticatorGroupsConfig|TestAccContainerNodePool_withWorkloadIdentityConfig|TestAccContainerCluster_nodeAutoprovisioningDefaultsMinCpuPlatform|TestAccContainerCluster_withMasterAuthConfig_NoCert|TestAccContainerCluster_withMonitoringConfig|TestAccContainerNodePool_withReservationAffinitySpecific|TestAccContainerCluster_withSoleTenantGroup|TestAccContainerCluster_withNodePoolResize|TestAccContainerCluster_withILBSubsetting|TestAccContainerCluster_withLoggingConfig|TestAccContainerCluster_withConfidentialNodes|TestAccContainerCluster_withNodePoolUpdateVersion|TestAccContainerCluster_withNodePoolBasic|TestAccContainerCluster_withIdentityServiceConfig|TestAccContainerCluster_withWorkloadIdentityConfig|TestAccContainerCluster_withNotificationConfig|TestAccContainerCluster_withAutopilotNetworkTags|TestAccContainerCluster_backend|TestAccContainerCluster_network|TestAccContainerCluster_withAddons|TestAccContainerCluster_errorAutopilotLocation|TestAccContainerCluster_withSandboxConfig|TestAccContainerCluster_withWorkloadMetadataConfig|TestAccContainerCluster_withAutopilot|TestAccContainerCluster_misc|TestAccContainerNodePool_compactPlacement|TestAccContainerNodePool_gvnic|TestAccContainerCluster_nodeAutoprovisioningNetworkTags|TestAccContainerCluster_withNodeConfigReservationAffinity|TestAccContainerCluster_nodeAutoprovisioningDefaults|TestAccContainerCluster_withNodeConfigShieldedInstanceConfig|TestAccContainerNodePool_withReservationAffinity|TestAccContainerCluster_nodeAutoprovisioning|TestAccContainerCluster_withNodeConfigScopeAlias|TestAccContainerCluster_networkingModeRoutes|TestAccContainerCluster_withIPAllocationPolicy_specificSizes|TestAccContainerNodePool_gcfsConfig|TestAccContainerNodePool_withNodeConfig|TestAccContainerCluster_basic|TestAccContainerCluster_withNodeConfig|TestAccContainerNodePool_ephemeralStorageConfig|TestAccContainerCluster_withBootDiskKmsKey|TestAccContainerNodePool_shieldedInstanceConfig|TestAccContainerCluster_withNodeConfigReservationAffinitySpecific|TestAccContainerCluster_updateVersion|TestAccContainerNodePool_maxPodsPerNode|TestAccContainerCluster_withIPAllocationPolicy_specificIPRanges|TestAccContainerCluster_withIPAllocationPolicy_existingSecondaryRanges|TestAccContainerCluster_deleteExclusionWindow|TestAccContainerCluster_updateMaintenanceExclusionOptions|TestAccContainerCluster_deleteMaintenanceExclusionOptions|TestAccContainerNodePool_basicWithClusterId|TestAccContainerNodePool_nodeLocations|TestAccContainerCluster_withMaintenanceExclusionOptions|TestAccContainerCluster_withMaintenanceExclusionWindow|TestAccContainerNodePool_basic|TestAccContainerCluster_withRecurringMaintenanceWindow|TestAccContainerCluster_withMaintenanceWindow|TestAccContainerCluster_withNodePoolNodeConfig|TestAccContainerNodePool_EmptyGuestAccelerator|TestAccContainerCluster_withVersion|TestAccContainerCluster_withTPUConfig|TestAccContainerNodePool_012_ConfigModeAttr|TestAccContainerNodePool_regionalClusters|TestAccContainerNodePool_version|TestAccContainerCluster_withDNSConfig|TestAccContainerCluster_withNodePoolMultiple|TestAccContainerNodePool_resize|TestAccContainerCluster_withEnableKubernetesAlpha|TestAccContainerNodePool_autoscaling|TestAccContainerCluster_withIntraNodeVisibility|TestAccContainerCluster_withNodePoolAutoscaling|TestAccContainerCluster_withMasterAuthorizedNetworksDisabled|TestAccContainerCluster_withPrivateClusterConfigMissingCidrBlock_withAutopilot|TestAccContainerCluster_withResourceUsageExportConfig|TestAccContainerCluster_withAdvancedDatapath|TestAccContainerNodePool_regionalAutoscaling|TestAccContainerNodePool_withNodeConfigScopeAlias|TestAccContainerNodePool_withManagement|TestAccContainerCluster_withDatabaseEncryption|TestAccContainerCluster_withMeshCertificatesConfig|TestAccContainerCluster_errorNoClusterCreated|TestAccContainerNodePool_withGPU|TestAccContainerCluster_withPrivateClusterConfig|TestAccContainerCluster_errorCleanDanglingCluster|TestAccContainerCluster_withTpu|TestAccContainerCluster_nodeAutoprovisioningDefaultsImageType|TestAccContainerCluster_withFlexiblePodCIDR|TestAccContainerCluster_regionalWithNodeLocations|TestAccContainerCluster_withBinaryAuthorizationEvaluationModeClassic|TestAccContainerCluster_regionalWithNodePool|TestAccContainerCluster_regional|TestAccContainerCluster_nodeAutoprovisioningDefaultsBootDiskKmsKey|TestAccContainerCluster_withMasterAuthorizedNetworksConfig|TestAccContainerCluster_withBinaryAuthorizationEvaluationModeAutopilot|TestAccContainerCluster_withTelemetryEnabled|TestAccContainerCluster_withReleaseChannelEnabledDefaultVersion|TestAccContainerCluster_withReleaseChannelEnabled|TestAccContainerCluster_withNetworkPolicyEnabled|TestAccComputeInstance_soleTenantNodeAffinities|TestAccComputeNetworkPeeringRoutesConfig_networkPeeringRoutesConfigGkeExample|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccCloudRunService_cloudRunServiceStaticOutboundExample|TestAccCGCSnippet_eventarcWorkflowsExample|TestAccBigtableAppProfile_bigtableAppProfileMulticlusterExample|TestAccBigtableAppProfile_bigtableAppProfileSingleclusterExample|TestAccFirebaserulesRelease_BasicRelease|TestAccGKEHubMembership_gkehubMembershipIssuerExample|TestAccGKEHubMembership_gkehubMembershipBasicExample|TestAccContainerClusterDatasource_zonal|TestAccContainerClusterDatasource_regional

@renescheepers renescheepers marked this pull request as ready for review August 26, 2022 06:38
@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, 1 insertion(+))
Terraform Beta: Diff ( 2 files changed, 116 insertions(+), 5 deletions(-))
TF Validator: Diff ( 2 files changed, 3 insertions(+), 3 deletions(-))

@modular-magician
Copy link
Collaborator

Tests analytics

Total tests: 2147
Passed tests 1906
Skipped tests: 232
Failed tests: 9

Action taken

Triggering VCR tests in RECORDING mode for the tests that failed during VCR. Click here to see the failed tests
TestAccComputeInstance_soleTenantNodeAffinities|TestAccComputeGlobalForwardingRule_internalLoadBalancing|TestAccCloudFunctions2Function_fullUpdate|TestAccCloudRunService_cloudRunServiceStaticOutboundExample|TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange|TestAccContainerCluster_withCostManagementConfig|TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample|TestAccFirebaserulesRelease_BasicRelease|TestAccSqlDatabaseInstance_SqlServerAuditConfig

@modular-magician
Copy link
Collaborator

Tests passed during RECORDING mode:
TestAccContainerCluster_withCostManagementConfig[view]
TestAccFirebaserulesRelease_BasicRelease[view]

Tests failed during RECORDING mode:
TestAccComputeInstance_soleTenantNodeAffinities[view]
TestAccComputeGlobalForwardingRule_internalLoadBalancing[view]
TestAccCloudFunctions2Function_fullUpdate[view]
TestAccCloudRunService_cloudRunServiceStaticOutboundExample[view]
TestAccSqlDatabaseInstance_withPrivateNetwork_withAllocatedIpRange[view]
TestAccPrivatecaCertificateAuthority_privatecaCertificateAuthoritySubordinateExample[view]
TestAccSqlDatabaseInstance_SqlServerAuditConfig[view]

Please fix these to complete your PR
View the build log or the debug log for each test

@renescheepers
Copy link
Contributor Author

@c2thorn are you able to see why those tests are failing? I don't think my changes should have had any effect on those tests.

Copy link
Member

@c2thorn c2thorn left a comment

Choose a reason for hiding this comment

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

LGTM. Other tests are not related. Thanks @renescheepers

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

Successfully merging this pull request may close these issues.

google_container_cluster: enabling cost allocation
3 participants