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
116 stars 59 forks source link

[BUG] Importing citrixadc_systemfile fails #1120

Open ravager-dk opened 5 months ago

ravager-dk commented 5 months ago

Contact us

For any immediate issues or help , reach out to us at NetScaler-AutomationToolkit@cloud.com !

Bug Report

Describe the bug Importing citrixadc_systemfile fails with error:

citrixadc_systemfile.sshd_config: Import prepared!
  Prepared citrixadc_systemfile for import
citrixadc_systemfile.sshd_config: Refreshing state... [id=/etc/sshd_config]
╷
│ Error: Request cancelled
│ 
│ The plugin.(*GRPCProvider).ReadResource request was cancelled.
╵

Stack trace from the terraform-provider-citrixadc_v1.37.0 plugin:

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

goroutine 115 [running]:
github.com/citrix/terraform-provider-citrixadc/citrixadc.readSystemfileFunc(0xc000c06930, {0x14539c0?, 0xc000ea44c0})
    github.com/citrix/terraform-provider-citrixadc/citrixadc/resource_citrixadc_systemfile.go:134 +0x550
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc0005dbd60, 0xc000c0caa0, {0x14539c0, 0xc000ea44c0})
    github.com/hashicorp/terraform-plugin-sdk@v1.[17](https://github.com/ravager-dk/Terraform-ADC-demo/actions/runs/7754063917/job/21146642551#step:4:18).2/helper/schema/resource.go:470 +0x1aa
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ReadResource(0xc0005dd230, {0xc000578[18](https://github.com/ravager-dk/Terraform-ADC-demo/actions/runs/7754063917/job/21146642551#step:4:19)0?, 0x5beae6?}, 0xc000578180)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:535 +0x365
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ReadResource_Handler({0x1629c80?, 0xc0005dd230}, {0x1b090c0, 0xc000c00d20}, 0xc000c06460, 0x0)
    github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3269 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000a66000, {0x1b0dfe0, 0xc000842000}, 0xc000d01320, 0xc000a64a80, 0x23d[19](https://github.com/ravager-dk/Terraform-ADC-demo/actions/runs/7754063917/job/21146642551#step:4:20)50, 0x0)
    google.golang.org/grpc@v1.52.0/server.go:1336 +0xd33
google.golang.org/grpc.(*Server).handleStream(0xc000a66000, {0x1b0dfe0, 0xc00084[20](https://github.com/ravager-dk/Terraform-ADC-demo/actions/runs/7754063917/job/21146642551#step:4:21)00}, 0xc000d01320, 0x0)
    google.golang.org/grpc@v1.52.0/server.go:1704 +0xa36
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.[37] 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.

To Reproduce Steps to reproduce the behaviour:

  1. My terraform files are

    resource "citrixadc_systemfile" "sshd_config" {
    filename = "sshd_config"
    filelocation = "/etc"
    filecontent = file("${path.module}/sshd_config")
    } 
    terraform {
    required_providers {
    citrixadc = {
      source  = "citrix/citrixadc"
      version = "~>1.37"
    }
    }
    }
    provider "citrixadc" {
    endpoint             = "https://${var.primaryNSIP}:443"
    username             = var.nsuser
    password             = var.nspassword
    insecure_skip_verify = true
    }
  2. which terraform command I am getting the error

    # terrafrom import citrixadc_systemfile.sshd_config /etc/sshd_config
  3. Terraform output logs to the log file (./tf.log). Append TF_LOG=TRACE NS_LOG=TRACE TF_LOG_PATH=./tf.log to your terraform command tl_logs cannot currently be captured from the pipeline used. I will try to get these from a local test

  4. Error I am facing on the console See error above

Expected behaviour The file should be imported correctly into state for further modifications in the config later

Screenshots If applicable, add screenshots to help explain your problem.

Environment (please fill the following information):

Additional context Add any other context about the problem here.

rohit-myali commented 5 months ago

Thanks @ravager-dk for contacting. We are working on it, I will update you, as soon we release it to terraform registry!

Thanks Rohit