citrix / terraform-provider-citrix

Terraform Provider for Citrix
https://registry.terraform.io/providers/citrix/citrix/latest
Apache License 2.0
46 stars 6 forks source link

With new version 0.3.6 I cannot create a machine catalog in Azure #31

Closed dimi4ik closed 10 months ago

dimi4ik commented 10 months ago

Terraform Core Version

he semantic version of Terraform Core used when experiencing the bug. If multiple versions have been tested, a comma separated list.

Terraform v1.5.6 on linux_amd64

Description

The Terraform plan works and shows the data for new MC, but when I create a new MC I get the following error

error: Unexpected error in the Citrix provider

If you need further logs/data from me, please send me a PM

Affected Resource(s)

Please list the affected resource(s) and/or data source(s). citrix_daas_machine_catalog

Expected Behavior

What should have happened? a new MC should be created.

Relevant Error/Panic Output Snippet

If applicable, provide a relevant snippet from the error or panic output. This will be rendered as shell, so there is no need to add a

error: Unexpected error in the Citrix provider
│ 
│   with citrix_daas_machine_catalog.example-azure-mtsession,
│   on 06_machine_catalog.tf line 44, in resource "citrix_daas_machine_catalog" "example-azure-mtsession":
│   44: resource "citrix_daas_machine_catalog" "example-azure-mtsession" {
│ 
│ An unexpected error occurred in runtime.goPanicIndex.
│ 
│ runtime error: index out of range [-1]
│ 
│ Please report this issue to the project maintainers and include this file if present: /tmp/citrix_provider_crash_stack.3662928135.txt

Terraform Configuration Files

rresource "citrix_daas_machine_catalog" "example-azure-mtsession" {
  name = "MCName"

  zone              = citrix_daas_zone.zone.id
  provisioning_type = "MCS"
  allocation_type   = "Random"
  session_support   = "MultiSession"
  is_power_managed  = true
  is_remote_pc      = false

  provisioning_scheme = {
    machine_config = {
      hypervisor               = "ID"
      hypervisor_resource_pool = "ID"
      service_offering         = "Standard_D2_v2"
      resource_group           = "rg-ctx-prod"
      master_image             = "OsDisk_1"
      service_account          = "user"
      service_account_password = var.service_account_password
    }
    network_mapping = {
      network_device = "0"
      network        = azurerm_virtual_network.example.name
    }
    number_of_total_machines = 1
    machine_account_creation_rules = {
      naming_scheme      = "name##"
      naming_scheme_type = "Numeric"
      domain             = "domain.com"
    }
    os_type           = "Windows"
    storage_type      = "Standard_LRS"
    use_managed_disks = true

  }
}

Debug Output

2024-01-15T12:41:17.037+0100 [ERROR] provider.terraform-provider-citrix_v0.3.6: Response contains error diagnostic: tf_resource_type=citrix_daas_machine_catalog @module=sdk.proto diagnostic_summary="Unexpected error in the Citrix provider" tf_proto_version=6.4 tf_provider_addr=registry.terraform.io/citrix/citrix @caller=github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/diag/diagnostics.go:62 diagnostic_detail="An unexpected error occurred in runtime.goPanicIndex.

Panic Output

If Terraform produced a panic, please paste, upload, or link to a file or Gist containing the output of the crash.log.

goroutine 53 [running]:
runtime/debug.Stack()
        runtime/debug/stack.go:24 +0x5e
github.com/citrix/terraform-provider-citrix/internal/util.PanicHandler(0x0?)
        github.com/citrix/terraform-provider-citrix/internal/util/common.go:208 +0x125
panic({0x141cc60?, 0xc0000f22e8?})
        runtime/panic.go:914 +0x21f
github.com/citrix/terraform-provider-citrix/internal/daas/resources/machine_catalog.ParseNetworkMappingToClientModel({{0x2, {0x214eea0, 0x1}}, {0x2, {0xc000266d90, 0x10}}}, 0xc000216000)
        github.com/citrix/terraform-provider-citrix/internal/daas/resources/machine_catalog/machine_catalog_resource_model.go:399 +0x489
github.com/citrix/terraform-provider-citrix/internal/daas/resources/machine_catalog.getProvSchemeForCatalog({0x16b47e8, 0xc0005eecc0}, _, {{0x1, {0x0, 0x0}}, {0x2, {0xc00039a330, 0x15}}, {0x0, ...}, ...}, ...)
        github.com/citrix/terraform-provider-citrix/internal/daas/resources/machine_catalog/machine_catalog_resource.go:1714 +0x1ab9
github.com/citrix/terraform-provider-citrix/internal/daas/resources/machine_catalog.(*machineCatalogResource).Create(0xc0000ca080, {0x16b47e8, 0xc0005eecc0}, {{{{0x16b91b0, 0xc0005d9f80}, {0x133d060, 0xc0005ae630}}, {0x16baba8, 0xc0000ce730}}, {{{0x16b91b0, ...}, ...}, ...}, ...}, ...)
        github.com/citrix/terraform-provider-citrix/internal/daas/resources/machine_catalog/machine_catalog_resource.go:530 +0x353
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).CreateResource(0xc000255380, {0x16b47e8, 0xc0005eecc0}, 0xc000225318, 0xc0002252b8)
        github.com/hashicorp/terraform-plugin-framework@v1.5.0/internal/fwserver/server_createresource.go:101 +0x578
github.com/hashicorp/terraform-plugin-framework/internal/fwserver.(*Server).ApplyResourceChange(0xc00051f470?, {0x16b47e8, 0xc0005eecc0}, 0xc0001c6aa0, 0xc000225470)
        github.com/hashicorp/terraform-plugin-framework@v1.5.0/internal/fwserver/server_applyresourcechange.go:57 +0x4a5
github.com/hashicorp/terraform-plugin-framework/internal/proto6server.(*Server).ApplyResourceChange(0xc000255380, {0x16b47e8?, 0xc0005eeba0?}, 0xc0001c6910)
        github.com/hashicorp/terraform-plugin-framework@v1.5.0/internal/proto6server/server_applyresourcechange.go:55 +0x3e5
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc00026d180, {0x16b47e8?, 0xc0005ee1e0?}, 0xc0001c4230)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/tf6server/server.go:857 +0x56b
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x14686e0?, 0xc00026d180}, {0x16b47e8, 0xc0005ee1e0}, 0xc000486080, 0x0)
        github.com/hashicorp/terraform-plugin-go@v0.20.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:503 +0x169
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000195000, {0x16b47e8, 0xc0005ee150}, {0x16b9a20, 0xc00009ad00}, 0xc000580000, 0xc0002bbe60, 0x21ac4b8, 0x0)
        google.golang.org/grpc@v1.60.1/server.go:1372 +0xe03
google.golang.org/grpc.(*Server).handleStream(0xc000195000, {0x16b9a20, 0xc00009ad00}, 0xc000580000)
        google.golang.org/grpc@v1.60.1/server.go:1783 +0xfec
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        google.golang.org/grpc@v1.60.1/server.go:1016 +0x59
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 23
        google.golang.org/grpc@v1.60.1/server.go:1027 +0x115
zhuolun-citrix commented 10 months ago

Hi @dimi4ik,

Thanks for reporting the issue. From your terraform, looks like you are using the VNet name azurerm_virtual_network.example.name on Azure to create the network interface. However, it should be one of the subnet available from the hypervisor resource pool you are using for the catalog.

Please refer to the documentation for the network field in network_mapping: https://registry.terraform.io/providers/citrix/citrix/latest/docs/resources/daas_machine_catalog#network

However, provider should have handled this case as an error and fail the terraform apply job, instead of just crashing. We will address this in the next release.

Thank you!

dimi4ik commented 10 months ago

hi @zhuolun-citrix, Thanks, that was my typo, I actually assigned the wrong network.