resource hooks seem broken on non-AWS ? I am tryi...
# general
s
resource hooks seem broken on non-AWS ? I am trying to use a resource hook in Go with Hetzner Cloud (hcloud). To the best of my understanding, I adapted the Go example at pulumi.com/docs/…/hooks#… from AWS to Hetzner Cloud and I get the following error:
Copy code
error: after hook "health-check" failed:
rpc error: code = Unavailable desc = error reading from server: EOF
I opened issue github.com/pulumi/pulumi/issues/24158 Am I doing something wrong or is there a bug ? thanks!
e
This looks like a bug, I don't think there's anything wrong with the code shown on the issue.
Alright, partly an us bug, partly a you bug. The hook function panic'd and that tore down the whole process, that's a bug on us, I'm getting that fixed so a panic in a hook just reports the hook as failed not EOF. Your bug is that a hcloud server doesn't have a publicIp field so the line
publicIp := args.NewOutputs["publicIp"].StringValue()
panics trying to call
StringValue()
on a nil value.
s
Thanks for the quick confirmation Fraser! > Your bug is that a hcloud server doesn't have a publicIp field so the line
publicIp := args.NewOutputs["publicIp"].StringValue()
panics trying to call
StringValue()
on a nil value. I think that the error on my part was keeping the string
"publicIp"
when exporting the existing field `server.Ipv6Address`:
Copy code
ctx.Export("publicIp", server.Ipv6Address)
(see towards the end of the main() function in the issue) So I think that the code doesn't panic, because the string "publicIp" should be present in
args.NewOutputs["publicIp"]
?
Is anything else that I should do to help the issue to be triaged ?
e
args.NewOutputs is the new outputs of the resource running against the hook, which in your code is the
hcloud.NewServer
. The
ctx.Export
is to set the stack outputs, not the resource outputs. If you change that string to "ipv6Address" it should see the output on the server.
s
Finally understood! Thanks!
e
n/p