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

Crash during VDC creation #1098

Closed
bogi0704 opened this issue Jul 26, 2023 · 6 comments
Closed

Crash during VDC creation #1098

bogi0704 opened this issue Jul 26, 2023 · 6 comments
Assignees

Comments

@bogi0704
Copy link
Contributor

bogi0704 commented Jul 26, 2023

Hello,

Thank you for opening an issue. Please note that we try to keep the Terraform issue tracker reserved
for bug reports and feature requests. For general usage questions, please see:
https://www.terraform.io/community.html.

Terraform Version

Terraform v1.5.3

Affected Resource(s)

Please list the resources as a list, for example:

  • vcd_org_vdc

Terraform Configuration Files

  # module.***.vcd_org_vdc.main will be created
  + resource "vcd_org_vdc" "main" {
      + allocation_model                 = "AllocationVApp"
      + allow_over_commit                = (known after apply)
      + cpu_guaranteed                   = 0
      + cpu_speed                        = 2000
      + default_compute_policy_id        = (known after apply)
      + default_vm_sizing_policy_id      = (known after apply)
      + delete_force                     = true
      + delete_recursive                 = true
      + description                      = "***"
      + elasticity                       = (known after apply)
      + enable_fast_provisioning         = false
      + enable_nsxv_distributed_firewall = (known after apply)
      + enable_thin_provisioning         = true
      + enable_vm_discovery              = true
      + enabled                          = true
      + id                               = (known after apply)
      + include_vm_memory_overhead       = (known after apply)
      + memory_guaranteed                = 0
      + metadata                         = {
          + "***"    = "***"
          + "***"           = "******"
          + "***"     = "***"
          +"***"     = "***"
          + "***"                         = "***"
          + "***"                     = "***"
          + "***"                 = "***"
        }
      + name                             = "VDC_NAME"
      + network_pool_name                = "nPool-01"
      + network_quota                    = 20
      + nic_quota                        = 0
      + org                              = "ORG_NAME"
      + provider_vdc_name                = "pVDC-01"
      + vm_placement_policy_ids          = (known after apply)
      + vm_quota                         = 0
      + vm_sizing_policy_ids             = (known after apply)

      + compute_capacity {
          + cpu {
              + allocated = 0
              + limit     = 0
              + reserved  = (known after apply)
              + used      = (known after apply)
            }
          + memory {
              + allocated = 0
              + limit     = 0
              + reserved  = (known after apply)
              + used      = (known after apply)
            }
        }

      + storage_profile {
          + default            = false
          + enabled            = true
          + limit              = 0
          + name               = "Profile1"
          + storage_used_in_mb = (known after apply)
        }
      + storage_profile {
          + default            = false
          + enabled            = true
          + limit              = 0
          + name               = "Profile2"
          + storage_used_in_mb = (known after apply)
        }
      + storage_profile {
          + default            = true
          + enabled            = true
          + limit              = 0
          + name               = "Profile3"
          + storage_used_in_mb = (known after apply)
        }
    }

Panic Output

Error: Request cancelled

  with module.***.vcd_org_vdc.main,
  on /tmp/***.vdc/010_main.tf line 38, in resource "vcd_org_vdc" "main":
  38: resource "vcd_org_vdc" "main" {

The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.

Stack trace from the terraform-provider-vcd_v3.10.0 plugin:

panic: assignment to entry in nil map

goroutine 65 [running]:
github.com/vmware/go-vcloud-director/v2/govcd.(*Client).cumulativeQueryWithHeaders(0xc000198a00, {0xff4a62, 0x19}, 0x4?, 0x0?, 0x30?)
	github.com/vmware/go-vcloud-director/v2@v2.21.0/govcd/query_metadata.go:251 +0x2f1
github.com/vmware/go-vcloud-director/v2/govcd.(*Client).cumulativeQuery(...)
	github.com/vmware/go-vcloud-director/v2@v2.21.0/govcd/query_metadata.go:188
github.com/vmware/go-vcloud-director/v2/govcd.(*VCDClient).QueryProviderVdcStorageProfileByName(0xc000198a00, {0xc0006433f0, 0x5}, {0xc0006d63f0, 0x61})
	github.com/vmware/go-vcloud-director/v2@v2.21.0/govcd/system.go:757 +0x11c
github.com/vmware/terraform-provider-vcd/v3/vcd.getVcdVdcInput(0xc0000cae00?, 0xc0000934f0)
	github.com/vmware/terraform-provider-vcd/v3/vcd/resource_vcd_org_vdc.go:1258 +0x137b
github.com/vmware/terraform-provider-vcd/v3/vcd.resourceVcdVdcCreate({0x11a4458, 0xc000647a40}, 0x0?, {0xfdab60?, 0xc0000934f0})
	github.com/vmware/terraform-provider-vcd/v3/vcd/resource_vcd_org_vdc.go:319 +0x505
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc000416380, {0x11a4490, 0xc0005cea80}, 0xd?, {0xfdab60, 0xc0000934f0})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:733 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc000416380, {0x11a4490, 0xc0005cea80}, 0xc0005031e0, 0xc0000caa80, {0xfdab60, 0xc0000934f0})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/resource.go:864 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000017b48, {0x11a4490?, 0xc0005ce960?}, 0xc000093590)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.27.0/helper/schema/grpc_provider.go:1024 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc000000320, {0x11a4490?, 0xc00009dce0?}, 0xc00033ebd0)
	github.com/hashicorp/terraform-plugin-go@v0.16.0/tfprotov5/tf5server/server.go:821 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0xf99e00?, 0xc000000320}, {0x11a4490, 0xc00009dce0}, 0xc00033eb60, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.16.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:422 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0003d81e0, {0x11a8be0, 0xc0002944e0}, 0xc00027d440, 0xc000283500, 0x17a42a0, 0x0)
	google.golang.org/grpc@v1.56.0/server.go:1337 +0xdf0
google.golang.org/grpc.(*Server).handleStream(0xc0003d81e0, {0x11a8be0, 0xc0002944e0}, 0xc00027d440, 0x0)
	google.golang.org/grpc@v1.56.0/server.go:1714 +0xa2f
google.golang.org/grpc.(*Server).serveStreams.func1.1()
	google.golang.org/grpc@v1.56.0/server.go:959 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/grpc@v1.56.0/server.go:957 +0x18c

Error: The terraform-provider-vcd_v3.10.0 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.

Expected Behavior

The VDC should have been created.

Actual Behavior

The provider crashed immediately.

Steps to Reproduce

terraform apply

User Access rights

System Administrator. Scope: System

Important Factoids

not that I know of

I will try to add more debug logs if that is necessary.

@dataclouder
Copy link
Contributor

dataclouder commented Jul 26, 2023

Hi @bogi0704 ,
Thanks for reporting this issue.
Could you add the HCL snippet for the VDC?
Also, which VCD version were you using?

@dataclouder
Copy link
Contributor

Related to issue #1066

@dataclouder
Copy link
Contributor

@bogi0704
One more question: how many storage profiles are in your system? We presume that this issue happens when the number of storage profiles is more than 25

@steadyjaw
Copy link
Contributor

steadyjaw commented Jul 27, 2023

Answering in behalf of @bogi0704

There is a total of:

  • storagePolicies: 7
  • pvdcStoragePolicies: 29

@dataclouder
Copy link
Contributor

dataclouder commented Jul 28, 2023

Here's an explanation of the failure:
The VCD contains 7 distinct storage profiles, which would be below the threshold of 25 items per page that the API needs to deal with when fetching storage profile information.
However, the API calls does not return the storage profiles without context: each storage profile is the combination of the original storage profile (from vSphere) and the provider VDC in which it is used. Meaning that if seven provider VDC use the same storage profile, we retrieve 7 records, not one. So, when we sum up all the provider VDC with the associated storage provider, we end up with 25 records.
Since 25 is the maximum allowed in a page of results, our code attempts a second call, increasing the page number by 1. This is where the bug was, and it was causing a crash.

Summing up: if the total number of storage profiles, including duplicates, is lower than 25, the system works as expected. But if we reach 25, the bug kicks in and we get a crash.

We have fixed the routine that fetches storage profiles, and the bug will be fixed in the next release.

@dataclouder
Copy link
Contributor

Fixed in PR #598

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

No branches or pull requests

3 participants