TelkomIndonesia / terraform-provider-linux

terraform provider for managing linux machine via ssh
Mozilla Public License 2.0
16 stars 6 forks source link

Error: Plugin did not respond #13

Open jmadison222 opened 1 year ago

jmadison222 commented 1 year ago

Doing "terraform apply" causes this:

linux_directory.directory: Refreshing state... [id=58a20ba3-73e8-4e8d-a576-2a5ae6ca823b]
╷
│ Error: Plugin did not respond
│
│   with linux_directory.directory,
│   on linux.tf line 23, in resource "linux_directory" "directory":
│   23: resource "linux_directory" "directory" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ReadResource call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-linux_v0.7.0 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xecaa27]

goroutine 12 [running]:
github.com/TelkomIndonesia/terraform-provider-linux/linux.handlerDirectoryResource.Read(0x12f1d80, 0xc0006716e0, 0xc000167500, 0xfccc00, 0xc0002a3ce0, 0x12f1d80, 0xc0006716e0, 0xc0001a0b00)
        github.com/TelkomIndonesia/terraform-provider-linux/linux/directory-resource.go:153 +0x287
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).read(0xc000148d20, 0x12f1d00, 0xc0004e6b80, 0xc000167500, 0xfccc00, 0xc0002a3ce0, 0x0, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.7.0/helper/schema/resource.go:347 +0x17c
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).RefreshWithoutUpgrade(0xc000148d20, 0x12f1d00, 0xc0004e6b80, 0xc000186770, 0xfccc00, 0xc0002a3ce0, 0xc00000e7e0, 0x0, 0x)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.7.0/helper/schema/resource.go:624 +0x1cb
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ReadResource(0xc0005206c0, 0x12f1d00, 0xc0004e6b80, 0xc0004e6bc0, 0xc0004e6b80, 0x10af7a0, 0x10ffa80)
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.7.0/helper/schema/grpc_provider.go:575 +0x43b
github.com/hashicorp/terraform-plugin-go/tfprotov5/server.(*server).ReadResource(0xc0004d9f40, 0x12f1d00, 0xc0004e6b80, 0xc000671260, 0xc0004d9f40, 0xc00067b410, 0xc00009eba0)
        github.com/hashicorp/terraform-plugin-go@v0.3.0/tfprotov5/server/server.go:298 +0x105
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ReadResource_Handler(0x10ffa80, 0xc0004d9f40, 0x12f1dc0, 0xc00067b410, 0xc000671200, 0x0, 0x12f1dc0, 0xc00067b4)
        github.com/hashicorp/terraform-plugin-go@v0.3.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:344 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0000b6380, 0x12fcd20, 0xc000001500, 0xc000096a00, 0xc0004e8ed0, 0x191fdd0, 0x0, 0x0, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1194 +0x522
google.golang.org/grpc.(*Server).handleStream(0xc0000b6380, 0x12fcd20, 0xc000001500, 0xc000096a00, 0x0)
        google.golang.org/grpc@v1.32.0/server.go:1517 +0xd05
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0000383d0, 0xc0000b6380, 0x12fcd20, 0xc000001500, 0xc000096a00)
        google.golang.org/grpc@v1.32.0/server.go:859 +0xa5
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.32.0/server.go:857 +0x1fd

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

The "linux.tf" file is:

terraform {
  required_providers {
    linux = {
      source  = "telkomIndonesia/linux"
      version = "~> 0.7.0"
    }
  }
}

provider "linux" {
    host     = "127.0.0.1"
    port     = 22
    user     = "james"
    password = "james"
}

resource "linux_directory" "directory" {
    path = "/tmp/james.terraform"
    owner = 1005
    group = 1005
    mode = "755"
    overwrite = true
    recycle_path = "/tmp/recycle"
}

The system configuration is:

-- System:
Linux ip-172-23-5-100.ec2.internal 3.10.0-1160.95.1.el7.x86_64 #1 SMP Fri Jun 23 08:44:55 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux
-- Release:
NAME="Red Hat Enterprise Linux Server"
VERSION="7.9 (Maipo)"
ID="rhel"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.9"
PRETTY_NAME="Red Hat Enterprise Linux Server 7.9 (Maipo)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:7.9:GA:server"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 7"
REDHAT_BUGZILLA_PRODUCT_VERSION=7.9
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="7.9"
Red Hat Enterprise Linux Server release 7.9 (Maipo)
Red Hat Enterprise Linux Server release 7.9 (Maipo)
-- Bash:
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

The account I'm using has this entry in /etc/passwd:

james:x:1005:1005::/home/james:/bin/bash

The sudoers file has:

james ALL=(ALL:ALL) ALL

I'm just trying to do a "hello world" to kick the tires at this point. It did work once in that it made the directory. But that gave an error. I didn't capture that error, but it wasn't a crash. Then when I ran it again, it produced the crash above. I tried purging the .terraform directory and the .terraform.lock.hcl file but it didn't help.

rucciva commented 1 year ago

Hi @jmadison222 , thanks for reaching out.

is the problem permanent? because i'm seeing this too with other providers. I just re-run the terraform and it will works