citrix / terraform-provider-citrixadc

Part of NetScaler Automation Toolkit | https://github.com/netscaler/automation-toolkit
https://registry.terraform.io/providers/citrix/citrixadc
Apache License 2.0
119 stars 59 forks source link

[Bug]: Provider crashes on 'citrixadc_cachecontentgroup' due to incorrect 'cachecontrol' type definition #1171

Closed ricohomewood closed 4 months ago

ricohomewood commented 5 months ago

Terraform Core Version

1.8.5

citrixadc Provider Version

1.39

Operating system

Windows 11

Affected Resource(s)

Equivalent NetScaler CLI Command

add cache contentGroup MyPage.aspx -relExpiry 3 -prefetch NO -flashCache YES -cacheControl "max-age=3,public" -maxResSize 1000 -pinned YES -lazyDnsResolve NO -hitSelector queue-status-full-path -invalSelector queue-status-full-path

Expected Behavior

citrixadc_cachecontentgroup should get created with 'cachecontol' value set as a string

In the code, on line 324 of resource_citrixadc_cachecontentgroup.go this is incorrectly been defined as int when its actually a string so should be a simple fix.

if v, ok := d.GetOk("cachecontrol"); ok {
        cachecontentgroup["cachecontrol"] = v.(int)
    }

It should be:

if v, ok := d.GetOk("cachecontrol"); ok {
        cachecontentgroup["cachecontrol"] = v.(string)
    }

Actual Behavior

│ Error: Plugin did not respond │ │ with module.netscaler_config.module.netscaler_cache["queue-status"].citrixadc_cachecontentgroup.group, │ on config\cache\main.tf line 15, in resource "citrixadc_cachecontentgroup" "group": │ 15: resource "citrixadc_cachecontentgroup" "group" { │ │ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may │ contain more details.

This is because the

Relevant Error/Panic Output Snippet

Stack trace from the terraform-provider-citrixadc_v1.39.0.exe plugin:

panic: interface conversion: interface {} is string, not int

goroutine 33 [running]:
github.com/citrix/terraform-provider-citrixadc/citrixadc.createCachecontentgroupFunc(0x17867c0?, {0x16f1e80?, 0xc0006183c0})
        github.com/citrix/terraform-provider-citrixadc/citrixadc/resource_citrixadc_cachecontentgroup.go:324 +0x2614
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc0009f60a0, 0xc0004785a0, 0xc000ca4600, {0x16f1e80, 0xc0006183c0})
        github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:320 +0x438
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000046080, 0xc000d338c8, 0x19335ac?, 0xf?)
        github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x70
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000007a20, {0xc000648230?, 0x865386?}, 0xc000648230)
        github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x7c5
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x18c6320?, 0xc000007a20}, {0x1ddc2a0, 0xc000cc6630}, 0xc0006481c0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00032c000, {0x1ddfec8, 0xc000a36680}, 0xc000cb2120, 0xc000a2c3f0, 0x268a400, 0x0)
        google.golang.org/grpc@v1.52.0/server.go:1336 +0xd13
google.golang.org/grpc.(*Server).handleStream(0xc00032c000, {0x1ddfec8, 0xc000a36680}, 0xc000cb2120, 0x0)
        google.golang.org/grpc@v1.52.0/server.go:1704 +0xa1b
google.golang.org/grpc.(*Server).serveStreams.func1.2()
        google.golang.org/grpc@v1.52.0/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.52.0/server.go:963 +0x28a

Error: The terraform-provider-citrixadc_v1.39.0.exe 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.

Terraform Configuration Files

N/A

Steps to Reproduce

Create a cachecontentgroup with cachecontrol set:

resource "citrixadc_cachecontentgroup" "tf_cachecontentgroup" {
  name                 = "my_cachecontentgroup"
  heurexpiryparam      = 30
  prefetch             = "YES"
  quickabortsize       = 40
  ignorereqcachinghdrs = "YES"
  cachecontrol         = "max-age=3,public"
}

Run terraform apply and you will see the provider crash with

panic: interface conversion: interface {} is string, not int

Debug Output

No response

Panic Output

Stack trace from the terraform-provider-citrixadc_v1.39.0.exe plugin:

panic: interface conversion: interface {} is string, not int

goroutine 33 [running]: github.com/citrix/terraform-provider-citrixadc/citrixadc.createCachecontentgroupFunc(0x17867c0?, {0x16f1e80?, 0xc0006183c0}) github.com/citrix/terraform-provider-citrixadc/citrixadc/resource_citrixadc_cachecontentgroup.go:324 +0x2614 github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Resource).Apply(0xc0009f60a0, 0xc0004785a0, 0xc000ca4600, {0x16f1e80, 0xc0006183c0}) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:320 +0x438 github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Provider).Apply(0xc000046080, 0xc000d338c8, 0x19335ac?, 0xf?) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x70 github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(GRPCProviderServer).ApplyResourceChange(0xc000007a20, {0xc000648230?, 0x865386?}, 0xc000648230) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x7c5 github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x18c6320?, 0xc000007a20}, {0x1ddc2a0, 0xc000cc6630}, 0xc0006481c0, 0x0) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0xc00032c000, {0x1ddfec8, 0xc000a36680}, 0xc000cb2120, 0xc000a2c3f0, 0x268a400, 0x0) google.golang.org/grpc@v1.52.0/server.go:1336 +0xd13 google.golang.org/grpc.(Server).handleStream(0xc00032c000, {0x1ddfec8, 0xc000a36680}, 0xc000cb2120, 0x0) google.golang.org/grpc@v1.52.0/server.go:1704 +0xa1b google.golang.org/grpc.(Server).serveStreams.func1.2() google.golang.org/grpc@v1.52.0/server.go:965 +0x98 created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.52.0/server.go:963 +0x28a

Error: The terraform-provider-citrixadc_v1.39.0.exe 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.

Important Factoids

No response

References

https://github.com/citrix/terraform-provider-citrixadc/blob/649dd257b5033c6d232ea7ed956dce17eeed5dee/citrixadc/resource_citrixadc_cachecontentgroup.go#L324 this line is where the error is, as per the NITRO API Schema, this should be a string with a minimum length of 1