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 fields to azurerm_*_cost_management_export: partition_data and export_data_options.data_version #26219

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

joshk0
Copy link

@joshk0 joshk0 commented Jun 4, 2024

Community Note

  • Please vote on this PR by adding a 👍 reaction to the original PR to help the community and maintainers prioritize for review
  • Please do not leave "+1" or "me too" comments, they generate extra noise for PR followers and do not help prioritize for review

Description

Add fields to azurerm_*_cost_management_export: partition_data and export_data_options.version.

export_data_options.version maps to export.definition.dataset.configuration.dataVersion - No default. Versions can proliferate and even though we can collect a large list of possible versions it's better to leave it free form.

partition_data maps to export.partition_data. Defaults to false.

PR Checklist

  • I have followed the guidelines in our Contributing Documentation.
  • I have checked to ensure there aren't other open Pull Requests for the same update/change.
  • I have checked if my changes close any open issues. If so please include appropriate closing keywords below.
  • I have updated/added Documentation as required written in a helpful and kind way to assist users that may be unfamiliar with the resource / data source.
  • I have used a meaningful PR title to help maintainers and other users understand this change and help prevent duplicate work.
    For example: “resource_name_here - description of change e.g. adding property new_property_name_here

Changes to existing Resource / Data Source

  • I have added an explanation of what my changes do and why I'd like you to include them (This may be covered by linking to an issue above, but may benefit from additional explanation).
  • I have written new tests for my resource or datasource changes & updated any relevent documentation.
  • I have successfully run tests with my changes locally. If not, please provide details on testing challenges that prevented you running the tests.
  • (For changes that include a state migration only). I have manually tested the migration path between relevant versions of the provider.

Testing

  • My submission includes Test coverage as described in the Contribution Guide and the tests pass. (if this is not possible for any reason, please include details of why you did or could not add test coverage)

Change Log

Below please provide what should go into the changelog (if anything) conforming to the Changelog Format documented here.

This is a (please select all that apply):

  • Bug Fix
  • New Feature (ie adding a service, resource, or data source)
  • Enhancement
  • Breaking Change

Related Issue(s)

Fixes #23747

Note

If this PR changes meaningfully during the course of review please update the title and description as required.

@joshk0 joshk0 changed the title Exports add fieldsdd fields to azurerm_*_cost_management_export: partition_data and export_data_options.data_version Add fields to azurerm_*_cost_management_export: partition_data and export_data_options.data_version Jun 4, 2024
@joshk0
Copy link
Author

joshk0 commented Jun 4, 2024

Please let me know if I need to run the live Azure acceptance tests myself in order to proceed.

@joshk0 joshk0 force-pushed the exports-add-fields branch from f945c9a to 6673a2e Compare June 4, 2024 17:12
@github-actions github-actions bot added size/M and removed size/XL labels Jun 4, 2024
@joshk0
Copy link
Author

joshk0 commented Jun 12, 2024

Hello, is it possible to get a review for this?

Copy link
Collaborator

@katbyte katbyte 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 the pr @joshk0 - for booleans we add _enabled to the end of them to mark them as bools. once that change is made i think this is good to go

@joshk0
Copy link
Author

joshk0 commented Jun 22, 2024

@katbyte, done. Please have a look. Thank you!

@joshk0
Copy link
Author

joshk0 commented Jul 3, 2024

I have rebased the branch to include the new go-azure-sdk. maybe it will work now?

Could someone please approve the workflows?

Copy link
Member

@stephybun stephybun 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 this PR @joshk0. There are some minor things that need fixing up to bring this more in-line with other resources in the provider.

Most resources have a basic and a complete test configuration, where the basic only includes properties that are Required and the complete configuration includes properties that are Optional. I see that we're missing a complete test config here, do you think you could look into adding that so we can validate the partition_data_enabled property?

@joshk0
Copy link
Author

joshk0 commented Jul 8, 2024

Hey there,

Most resources have a basic and a complete test configuration, where the basic only includes properties that are Required and the complete configuration includes properties that are Optional. I see that we're missing a complete test config here, do you think you could look into adding that so we can validate the partition_data_enabled property?

In other words, does this mean that the tests that already exist should in fact be left totally unmodified (currently we add data_version and partition_data_enabled values in the update flow, after merging your suggestions), and we add a new _complete test which does set those fields?

Or is it good to test the optional fields functioning properly in the update flow?

@joshk0
Copy link
Author

joshk0 commented Jul 8, 2024

Sorry, both update and requiresImport test case mutate the new optional fields.

Copy link
Member

@stephybun stephybun 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 making those changes @joshk0. Unfortunately now none of the test configs have partition_data_enabled so we're unable to test this change. As mentioned in my previous comment, we cannot add this property to the basic configuration since it's optional, and it cannot be added to the update configuration since it would trigger a ForceNew. Can you please add a complete test configuration that include this property?

@joshk0
Copy link
Author

joshk0 commented Jul 31, 2024

Thanks for making those changes @joshk0. Unfortunately now none of the test configs have partition_data_enabled so we're unable to test this change. As mentioned in my previous comment, we cannot add this property to the basic configuration since it's optional, and it cannot be added to the update configuration since it would trigger a ForceNew. Can you please add a complete test configuration that include this property?

Sure I was just asking a question and doing things that did not require an answer to that question (which you didn't directly answer, but did indirectly through hints in your answer.) I will add the test case now.

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Apologies @joshk0! I must have overlooked the question you left about the test when I did my re-review.

Thank you for adding the complete test configuration. I've kicked off the tests but we have some test failures:

------- Stdout: -------
=== RUN   TestAccResourceGroupCostManagementExport_complete
=== PAUSE TestAccResourceGroupCostManagementExport_complete
=== CONT  TestAccResourceGroupCostManagementExport_complete
    testcase.go:121: Step 1/2 error: Error running apply: exit status 1
        Error: creating Scoped Export (Scope: "/subscriptions/*******/resourceGroups/acctestRG-cm-240801080753627897"
        Export Name: "accrg240801080753627897"): unexpected status 400 (400 Bad Request) with error: BadRequest: Request properties validation failed: Invalid deliveryInfo destination rootFolderPath; value cannot begin with a forward slash
          with azurerm_resource_group_cost_management_export.test,
          on terraform_plugin_test.tf line 47, in resource "azurerm_resource_group_cost_management_export" "test":
          47: resource "azurerm_resource_group_cost_management_export" "test" {
        creating Scoped Export (Scope:
        "/subscriptions/*******/resourceGroups/acctestRG-cm-240801080753627897"
        Export Name: "accrg240801080753627897"): unexpected status 400 (400 Bad
        Request) with error: BadRequest: Request properties validation failed:
        Invalid deliveryInfo destination rootFolderPath; value cannot begin with a
        forward slash
--- FAIL: TestAccResourceGroupCostManagementExport_complete (132.73s)
FAIL
------- Stdout: -------
=== RUN   TestAccSubscriptionCostManagementExport_update
=== PAUSE TestAccSubscriptionCostManagementExport_update
=== CONT  TestAccSubscriptionCostManagementExport_update
    testcase.go:121: Step 1/6 error: Error running apply: exit status 1
        Error: creating Scoped Export (Scope: "/subscriptions/*******"
        Export Name: "accs240801080753607043"): unexpected status 400 (400 Bad Request) with error: BadRequest: Request properties validation failed: Export data version:  is not supported.
          with azurerm_subscription_cost_management_export.test,
          on terraform_plugin_test.tf line 52, in resource "azurerm_subscription_cost_management_export" "test":
          52: resource "azurerm_subscription_cost_management_export" "test" {
        creating Scoped Export (Scope:
        "/subscriptions/*******"
        Export Name: "accs240801080753607043"): unexpected status 400 (400 Bad
        Request) with error: BadRequest: Request properties validation failed: Export
        data version:  is not supported.
--- FAIL: TestAccSubscriptionCostManagementExport_update (157.92s)
FAIL

@joshk0
Copy link
Author

joshk0 commented Aug 5, 2024

Hi @stephybun , just pushed some fixes that I think will work? If you could kick off the flows when you have a chance.

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

@joshk0 unfortunately we're still getting the same failures:

=== CONT  TestAccResourceGroupCostManagementExport_basic
    testcase.go:121: Step 1/2 error: Error running apply: exit status 1
        Error: creating Scoped Export (Scope: "/subscriptions/*******/resourceGroups/acctestRG-cm-240807120359725390"
        Export Name: "accrg240807120359725390"): unexpected status 400 (400 Bad Request) with error: BadRequest: Request properties validation failed: Export data version:  is not supported.

joshk0 added 3 commits August 7, 2024 09:41
…bled` and `export_data_options.version`

`export_data_options.version` maps to
`export.definition.dataset.configuration.dataVersion` No default. Versions can
proliferate and even though we can collect a large list of possible versions
it's better to leave it free form.

`partition_data_enabled` maps to `export.partition_data`. Defaults to false.
@joshk0 joshk0 force-pushed the exports-add-fields branch from 6ad9b7d to 286c206 Compare August 7, 2024 13:41
@joshk0
Copy link
Author

joshk0 commented Aug 7, 2024

@stephybun one more time please

@joshk0
Copy link
Author

joshk0 commented Aug 7, 2024

I had to vendor so one more time again sorry @stephybun

Copy link
Member

@stephybun stephybun left a comment

Choose a reason for hiding this comment

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

Still receiving the same error:

        Error: creating Scoped Export (Scope: "/subscriptions/*******"
        Export Name: "accs240808092720759225"): unexpected status 400 (400 Bad Request) with error: BadRequest: Request properties validation failed: Export data version:  is not supported.

I currently don't have the capacity to dig deeper into this, best guess based on the error message being returned by the API

  • Property isn't properly supported by the API, I had a brief look in the portal and I don't see an option for data version
  • Value being used for data version isn't valid/supported

@joshk0
Copy link
Author

joshk0 commented Aug 8, 2024

Don't worry about trying to figure it out, I will just keep banging on it here just need the PRs to run

@joshk0
Copy link
Author

joshk0 commented Aug 8, 2024

@stephybun
How do I run these tests myself? I reviewed the log of the unit tests and it seems like different unit tests are failing. I think I need to see the full output of the test run to better understand what I need to do.

@joshk0
Copy link
Author

joshk0 commented Aug 8, 2024

BTW, this is the failure from the unit-test phase:

2024-08-08T09:17:26.6137210Z panic: test timed out after 30s
2024-08-08T09:17:26.6137509Z running tests:
2024-08-08T09:17:26.6137778Z    TestAccPluginSDKAndDecoder (30s)
2024-08-08T09:17:26.6138183Z    TestAccPluginSDKAndDecoderOptionalComputed (30s)
2024-08-08T09:17:26.6138723Z    TestAccPluginSDKAndDecoderOptionalComputedOverride (30s)
2024-08-08T09:17:26.6139208Z    TestAccPluginSDKAndDecoderSets (30s)
2024-08-08T09:17:26.6139560Z    TestAccPluginSDKAndEncoder (30s)
2024-08-08T09:17:26.6145361Z    TestAccPluginSDKReturnsComputedFields (30s)

@joshk0
Copy link
Author

joshk0 commented Aug 8, 2024

Property isn't properly supported by the API, I had a brief look in the portal and I don't see an option for data version

Yes, this is something you can only do via the console today.

Value being used for data version isn't valid/supported

Perhaps it has to be mandatory. The reality is that in the portal you get to choose among a variety of different versions based on the export you are making.

@@ -39,6 +39,25 @@ func TestAccBillingAccountCostManagementExport_basic(t *testing.T) {
})
}

func TestAccBillingAccountCostManagementExport_complete(t *testing.T) {
if os.Getenv("ARM_BILLING_ACCOUNT") == "" {

Choose a reason for hiding this comment

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

nit: Subscriptions are supported as well


"data_version": {
Type: pluginsdk.TypeString,
Optional: true,

Choose a reason for hiding this comment

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

I don't think this should be optional. I'm pretty sure it's required unless the API is defaulting.

@@ -6,10 +6,10 @@ package client
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2021-10-01/exports"
Copy link

@flanakin flanakin Aug 16, 2024

Choose a reason for hiding this comment

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

I would probably keep the old version as well. I believe there are some gaps between what's supported in each version.

@jojohpm would know more.

Copy link

Choose a reason for hiding this comment

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

If we have a provision to keep 2 versions, then we could keep both.
2021-10-01 = Exports v1. Legacy exports.
2023-07-01-preview = Exports v2. The new one with file partitioning, compression, file format, newer datasets etc... This is going to be the default experience going forward.

Copy link

@jojohpm jojohpm left a comment

Choose a reason for hiding this comment

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

Added the comment.

@@ -6,10 +6,10 @@ package client
import (
"fmt"

"github.com/hashicorp/go-azure-sdk/resource-manager/costmanagement/2021-10-01/exports"
Copy link

Choose a reason for hiding this comment

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

If we have a provision to keep 2 versions, then we could keep both.
2021-10-01 = Exports v1. Legacy exports.
2023-07-01-preview = Exports v2. The new one with file partitioning, compression, file format, newer datasets etc... This is going to be the default experience going forward.

@katbyte katbyte requested a review from a team as a code owner November 14, 2024 00:08
@wyattfry
Copy link
Collaborator

wyattfry commented Jan 2, 2025

Hello @joshk0 , could you fix the merge conflicts?

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

Successfully merging this pull request may close these issues.

Support for partition_data in azurerm_subscription_cost_management_export
7 participants