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

The provider crashes when the host has an IPv6 address #83

Open
beenum22 opened this issue Nov 28, 2023 · 0 comments
Open

The provider crashes when the host has an IPv6 address #83

beenum22 opened this issue Nov 28, 2023 · 0 comments

Comments

@beenum22
Copy link

beenum22 commented Nov 28, 2023

Hello. First of all, thank you for this amazing provider.

I tried to use the provider to connect to a host with IPv6 address and the provider crashed.

terraform {
  required_providers {
    ssh = {
      source = "loafoe/ssh"
      version = "2.6.0"
    }
  }
}

resource "ssh_resource" "test" {
  when = "create"
  host = "xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx"  # Obfuscated 
  user = "foo"
  private_key = sensitive(file("~/.ssh/id_rsa"))
  timeout = "5m"
  retry_delay = "5s"
  commands = [
    "ls /tmp"
  ]
}

I see the following logs when I apply the changes

ssh_resource.test: Creating...
╷
│ Error: Request cancelled
│
│   with ssh_resource.test,
│   on main.tf line 45, in resource "ssh_resource" "test":
│   45: resource "ssh_resource" "test" {
│
│ The plugin.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵

Stack trace from the terraform-provider-ssh_v2.6.0 plugin:

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

goroutine 54 [running]:
net/http.ProxyFromEnvironment(0x0)
	net/http/transport.go:448 +0x26
github.com/loafoe/easyssh-proxy/v2.(*MakeConfig).Connect(0xc00030cc50)
	github.com/loafoe/easyssh-proxy/[email protected]/easyssh.go:215 +0x28d
github.com/loafoe/easyssh-proxy/v2.(*MakeConfig).Stream(0x0?, {0xc00049c1d0, 0x7}, {0xc00049ca80, 0x1, 0x1})
	github.com/loafoe/easyssh-proxy/[email protected]/easyssh.go:340 +0xb0
github.com/loafoe/easyssh-proxy/v2.(*MakeConfig).Run(0x10?, {0xc00049c1d0?, 0xc000318e10?}, {0xc00049ca80?, 0xc00030c8b8?, 0x1015990?})
	github.com/loafoe/easyssh-proxy/[email protected]/easyssh.go:425 +0x47
github.com/loafoe/terraform-provider-ssh/ssh.runCommands({0x194c768, 0xc00030e8d0}, 0xc0000a48a0?, {0xc000318df0, 0x1, 0x0?}, 0x45d964b800, 0x98?, {0x17530a0, 0xc0000a48a0})
	github.com/loafoe/terraform-provider-ssh/ssh/resource_resource.go:445 +0x16b
github.com/loafoe/terraform-provider-ssh/ssh.mainRun({0x1176592c61f?, 0x18396a6?}, 0xc151aaaadc27ee78?, {0x17530a0?, 0xc0000a48a0}, 0x0)
	github.com/loafoe/terraform-provider-ssh/ssh/resource_resource.go:393 +0xa74
github.com/loafoe/terraform-provider-ssh/ssh.resourceResourceCreate({0x194c768, 0xc00030e6f0}, 0x0?, {0x17530a0, 0xc0000a48a0})
	github.com/loafoe/terraform-provider-ssh/ssh/resource_resource.go:425 +0xb7
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc00016cee0, {0x194c7a0, 0xc000548c60}, 0xd?, {0x17530a0, 0xc0000a48a0})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:707 +0x12e
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00016cee0, {0x194c7a0, 0xc000548c60}, 0xc000116820, 0xc00056e800, {0x17530a0, 0xc0000a48a0})
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/resource.go:837 +0xa85
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000397f98, {0x194c7a0?, 0xc000548b40?}, 0xc00054c460)
	github.com/hashicorp/terraform-plugin-sdk/[email protected]/helper/schema/grpc_provider.go:1021 +0xe8d
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0xc00024ea00, {0x194c7a0?, 0xc000548300?}, 0xc000568070)
	github.com/hashicorp/[email protected]/tfprotov5/tf5server/server.go:818 +0x574
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1811260?, 0xc00024ea00}, {0x194c7a0, 0xc000548300}, 0xc000568000, 0x0)
	github.com/hashicorp/[email protected]/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x170
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0002481e0, {0x1950398, 0xc00048c1a0}, 0xc000552120, 0xc0003c83c0, 0x1df3c00, 0x0)
	google.golang.org/[email protected]/server.go:1340 +0xd33
google.golang.org/grpc.(*Server).handleStream(0xc0002481e0, {0x1950398, 0xc00048c1a0}, 0xc000552120, 0x0)
	google.golang.org/[email protected]/server.go:1713 +0xa36
google.golang.org/grpc.(*Server).serveStreams.func1.2()
	google.golang.org/[email protected]/server.go:965 +0x98
created by google.golang.org/grpc.(*Server).serveStreams.func1
	google.golang.org/[email protected]/server.go:963 +0x28a

Error: The terraform-provider-ssh_v2.6.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 behaviour: Resource is created where it is able to execute commands on the remote machine.
Actual behaviour: Resource creation fails as the provider crashes.

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

No branches or pull requests

1 participant