pulumi / pulumi-hcloud

A Hetzner Cloud Pulumi resource package, providing multi-language access to Hetzner Cloud
Apache License 2.0
69 stars 6 forks source link

LoadBalancer ID no longer a number #160

Open t3hmrman opened 1 year ago

t3hmrman commented 1 year ago

What happened?

It seems like the Hetzner API has shifted over the years -- IDs for load balancers are no longer numbers, but instead numeric strings sometimes separated by dashes like the following:

nnnnnnn-nnnnnnn

Steps to reproduce

Expected Behavior

Creating a LoadBalancer with a LoadBalancerTarget and LoadBalancerServices should have succeeded when applied.

Actual Behavior

An error is produced:

Diagnostics:
  hcloud:index:LoadBalancerTarget (lb-tgt-0):
    error: hcloud:index/loadBalancerTarget:LoadBalancerTarget resource 'lb-tgt-0' has a problem: cannot parse '' as int: strconv.ParseInt: parsing "nnnnnnn-nnnnnnn": invalid syntax. Examine values at 'LoadBalancerTarget.LoadBalancerId'.                         

Output of pulumi about

CLI
Version 3.51.0
Go Version go1.19.4
Go Compiler gc

Plugins
NAME VERSION
aws 2.13.1
aws 2.13.1
hcloud 1.10.1
hcloud 1.10.1
nodejs unknown

Host
OS arch
Version "rolling"
Arch x86_64

Additional context

There is a work around which only works for LoadBalancerService and LoadBalancerNetwork:

const ctrlLBServiceK8s = new hcloud.LoadBalancerService(
  `lb-svc-k8s`,
  {
    loadBalancerId: lb.id.apply((v: string) => v as any),
    protocol: "tcp",
    destinationPort: xxxx,
    listenPort: xxxx,
  },
);

This works on the Typescript side and the resource is applied. I suspect this works since the load_balancer_id is a str in load_balancer_service.py. This trick does not work on the LoadBalancerTarget.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

thomas11 commented 1 year ago

Thanks for reporting this, @t3hmrman! It's an odd one since in the official docs of the latest version of Hetzner's own Terraform provider, load balancer ids are still ints. Same for the load_balancer_id parameter of hcloud_load_balancer_target, whereas the same load_balancer_id of hcloud_load_balancer_service is a string.

We'll be looking into this. We are a bit behind the upstream provider, so it might make sense for Pulumi to upgrade first (#159, cc @guineveresaenger).

t3hmrman commented 1 year ago

Hey @thomas11 thanks for taking a look -- I was really perplexed by this when it was coming up as an error (especially since the code had been working in a previous project) -- my first instinct was that something someone thought could be a "big int" ended up being much better as a string (and maybe eventually a UUID?) probably at the source :)

I wasn't able to find a work around (I could have either manually attached since the number of connections wasn't too huge, or used a different API from code, etc) but I'm sure someone motivated enough can either change the code or find a workaround.

t0yv0 commented 1 year ago

Hi @t3hmrman would it be possible to check if this is still an issue on the newly released v1.10.2? Thomas thought it might be fixed by the upstream provider upgrade.

t3hmrman commented 1 year ago

Hey @t0yv0 absolutely! Sorry I haven't been able to get around to this yet -- I changed the infrastructure a little bit.

Should be able to get to this by the end of the week.

t3hmrman commented 1 year ago

Finally got around to upgrading to v1.10.2 and the error is still there:


    VALUE: 1034544-2407574

  hcloud:index:LoadBalancerTarget (eu-central-0-ctrl-lb-tgt-0):
    error: hcloud:index/loadBalancerTarget:LoadBalancerTarget resource 'eu-central-0-ctrl-lb-tgt-0' has a problem: cannot parse '' as int: strconv.ParseInt: parsing "1034544-2407574": invalid syntax. Examine values at 'LoadBalancerTarget.LoadBalancerId'.
t0yv0 commented 1 year ago

Checked upstream again.

https://github.com/hetznercloud/terraform-provider-hcloud/blob/main/internal/loadbalancer/resource_target.go#L52 still an int

https://github.com/hetznercloud/terraform-provider-hcloud/blob/main/internal/loadbalancer/resource_service.go#L38 is a string here now

I believe the most straightforward way to fix this would be to submit a PR upstream to https://github.com/hetznercloud/terraform-provider-hcloud and have them do a patch release, then go through another round of upgrades here.

mjeffryes commented 2 months ago

Seems the upstream provider doesn't feel this pain because they internally use a string (even through they declare it as an int in TF schema?) (see https://github.com/hetznercloud/terraform-provider-hcloud/issues/862)