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

fix: azure ccm connector no billing export #637

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

rssnyder
Copy link
Contributor

@rssnyder rssnyder commented Jul 31, 2023

Describe your changes

Currently we do not allow creating azure ccm connectors with a billing export due to a bug where we try and grab the export information when we read the connector:

➜  test tf apply

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # harness_platform_connector_azure_cloud_cost.example will be created
  + resource "harness_platform_connector_azure_cloud_cost" "example" {
      + features_enabled = [
          + "OPTIMIZATION",
          + "VISIBILITY",
        ]
      + id               = (known after apply)
      + identifier       = "example"
      + name             = "example"
      + subscription_id  = "e8389fc5-0cb8-44ab-947b-c6cf62552be1"
      + tenant_id        = "b229b2bb-5f33-4d22-bce0-730f6474e906"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

harness_platform_connector_azure_cloud_cost.example: Creating...
╷
│ Error: Plugin did not respond
│ 
│   with harness_platform_connector_azure_cloud_cost.example,
│   on main.tf line 1, in resource "harness_platform_connector_azure_cloud_cost" "example":
│    1: resource "harness_platform_connector_azure_cloud_cost" "example" {
│ 
│ The plugin encountered an error, and failed to respond to the
│ plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-harness_v0.23.3 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10157599c]

goroutine 66 [running]:
github.com/harness/terraform-provider-harness/internal/service/platform/connector.readConnectorAzureCloudCost(0x101b03908?, 0x140001fe000)
        github.com/harness/terraform-provider-harness/internal/service/platform/connector/azure_cloud_cost.go:169 +0xdc
github.com/harness/terraform-provider-harness/internal/service/platform/connector.resourceConnectorAzureCloudCostCreateOrUpdate({0x101b03908, 0x140009e6840}, 0x0?, {0x1019c27e0, 0x140009c4f00})
        github.com/harness/terraform-provider-harness/internal/service/platform/connector/azure_cloud_cost.go:110 +0x64
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x140004fc2a0, {0x101b03940, 0x1400037d200}, 0xd?, {0x1019c27e0, 0x140009c4f00})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:733 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x140004fc2a0, {0x101b03940, 0x1400037d200}, 0x14000a4fd40, 0x140009e9680, {0x1019c27e0, 0x140009c4f00})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:864 +0x898
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x1400019c1e0, {0x101b03940?, 0x1400037d0e0?}, 0x14000275ea0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/grpc_provider.go:1024 +0xb94
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x140002fa280, {0x101b03940?, 0x1400037c6f0?}, 0x140009c15e0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/tf5server/server.go:821 +0x3c0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x101aa9340?, 0x140002fa280}, {0x101b03940, 0x1400037c6f0}, 0x140009c1570, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.18.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x1400044e000, {0x101b068e0, 0x140002f9860}, 0x14000000120, 0x140000ad260, 0x102176960, 0x0)
        google.golang.org/grpc@v1.56.2/server.go:1337 +0xc7c
google.golang.org/grpc.(*Server).handleStream(0x1400044e000, {0x101b068e0, 0x140002f9860}, 0x14000000120, 0x0)
        google.golang.org/grpc@v1.56.2/server.go:1714 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.1()
        google.golang.org/grpc@v1.56.2/server.go:959 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.56.2/server.go:957 +0x170

Error: The terraform-provider-harness_v0.23.3 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

This is fixed by checking the enabled features and only grabbing this information if BILLING is set on the connector:

➜  test tf plan
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - harness/harness in /Users/rileysnyder/git/terraform-provider-harness
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may
│ cause the state to become incompatible with published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # harness_platform_connector_azure_cloud_cost.example will be created
  + resource "harness_platform_connector_azure_cloud_cost" "example" {
      + features_enabled = [
          + "OPTIMIZATION",
          + "VISIBILITY",
        ]
      + id               = (known after apply)
      + identifier       = "example"
      + name             = "example"
      + subscription_id  = "e8389fc5-0cb8-44ab-947b-c6cf62552be1"
      + tenant_id        = "b229b2bb-5f33-4d22-bce0-730f6474e906"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly
these actions if you run "terraform apply" now.
➜  test tf apply
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - harness/harness in /Users/rileysnyder/git/terraform-provider-harness
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may
│ cause the state to become incompatible with published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # harness_platform_connector_azure_cloud_cost.example will be created
  + resource "harness_platform_connector_azure_cloud_cost" "example" {
      + features_enabled = [
          + "OPTIMIZATION",
          + "VISIBILITY",
        ]
      + id               = (known after apply)
      + identifier       = "example"
      + name             = "example"
      + subscription_id  = "e8389fc5-0cb8-44ab-947b-c6cf62552be1"
      + tenant_id        = "b229b2bb-5f33-4d22-bce0-730f6474e906"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

harness_platform_connector_azure_cloud_cost.example: Creating...
harness_platform_connector_azure_cloud_cost.example: Creation complete after 2s [id=example]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

related to
#617
#639

Comment Triggers

PR Check triggers
  • Build: trigger build
  • Sub Category Field Check: trigger subcategoryfieldcheck

@Rohit-Kaliki
Copy link
Contributor

trigger subcategoryfieldcheck

@Rohit-Kaliki
Copy link
Contributor

trigger build

@Rohit-Kaliki
Copy link
Contributor

trigger subcategoryfieldcheck

@Rohit-Kaliki
Copy link
Contributor

trigger build

@Rohit-Kaliki Rohit-Kaliki merged commit b27000b into harness:main Jul 31, 2023
2 checks passed
@rssnyder rssnyder deleted the fix/azure-ccm-nobill branch August 1, 2023 12:35
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.

None yet

2 participants