terraform-provider-digitalocean icon indicating copy to clipboard operation
terraform-provider-digitalocean copied to clipboard

floating_ip_assignment does not apply cleanly.

Open stillinbeta opened this issue 6 years ago • 12 comments

Terraform Version

$ terraform -v
Terraform v0.11.8
+ provider.digitalocean v1.0.0

Affected Resource(s)

Please list the resources as a list, for example:

  • digitalocean_floating_ip_assignment

If this issue appears to affect multiple resources, it may be an issue with Terraform's core, so please mention this.

Terraform Configuration Files

variable "digital_ocean_token" {}

provider "digitalocean" {
  token = "${var.digital_ocean_token}"
  version = "1.0.0"
}

resource "digitalocean_floating_ip" "ip" {
  region = "nyc1"
}

resource "digitalocean_droplet" "droplet" {
  name = "mastodon"
  image = "ubuntu-18-04-x64"
  region = "nyc1"
  size = "1gb"
}

resource "digitalocean_floating_ip_assignment" "ip_assignment"{
  droplet_id = "${digitalocean_droplet.droplet.id}"
  ip_address = "${digitalocean_floating_ip.ip.ip_address}"
}

Debug Output

https://gist.github.com/stillinbeta/20d7b6c52cb59a839b47ce0997451ebb

Panic Output

none

Expected Behavior

The floating IP address should be assigned and exit cleanly.

Actual Behavior

Behind the scenes the floating IP is assigned to the appropriate droplet, but it then errors out. Because of the error, the floating IP isn't marked as assigned in the terraform state, so it will try to apply the assignment again next time Terraform is executed.

Error: Error applying plan:

1 error(s) occurred:

* digitalocean_floating_ip_assignment.ip_assignment: 1 error(s) occurred:

* digitalocean_floating_ip_assignment.ip_assignment: Error Assigning FloatingIP (165.227.254.109) to the droplet: json: cannot unmarshal number 2783182445 into Go struct field Action.resource_id of type int

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. Define a digital ocean key under digital_ocean_api_key in e.g. terraform.tfvars
  2. terraform apply

Important Factoids

none

References

none

stillinbeta avatar Oct 08 '18 22:10 stillinbeta

You could use digitalocean_floating_ip to both create and assign the IP.

It works for me:

resource "digitalocean_droplet" "foobar" {
  name               = "baz"
  size               = "s-1vcpu-1gb"
  image              = "ubuntu-18-04-x64"
  region             = "sgp1"
  ipv6               = true
  private_networking = true
}

resource "digitalocean_floating_ip" "foobar" {
  droplet_id = "${digitalocean_droplet.foobar.id}"
  region     = "${digitalocean_droplet.foobar.region}"
}

Source: https://www.terraform.io/docs/providers/do/r/floating_ip.html#example-usage

ArtiomL avatar Oct 09 '18 19:10 ArtiomL

Same error:


1 error(s) occurred:

* digitalocean_floating_ip.ip: 1 error(s) occurred:

* digitalocean_floating_ip.ip: Error Assigning FloatingIP (174.138.109.215) to the droplet: json: cannot unmarshal number 2928307671 into Go struct field Action.resource_id of type int

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
variable "digital_ocean_token" {}

provider "digitalocean" {
  token = "${var.digital_ocean_token}"
  version = "1.0.0"
}

resource "digitalocean_floating_ip" "ip" {
  region = "nyc1"
  droplet_id = "${digitalocean_droplet.droplet.id}"
}

resource "digitalocean_droplet" "droplet" {
  name = "mastodon"
  image = "ubuntu-18-04-x64"
  region = "nyc1"
  size = "1gb"
}

stillinbeta avatar Oct 09 '18 19:10 stillinbeta

Could you try:

provider.digitalocean v1.0.2

That's what I'm using.

Thanks.

ArtiomL avatar Oct 09 '18 19:10 ArtiomL

It still crashes for me:

1 error(s) occurred:

* digitalocean_floating_ip.ip: 1 error(s) occurred:

* digitalocean_floating_ip.ip: Error Assigning FloatingIP (138.197.231.156) to the droplet: json: cannot unmarshal number 2328225692 into Go struct field Action.resource_id of type int

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.


zsh: exit 1     terraform apply tf.plan
terraform apply tf.plan  0.89s user 0.57s system 4% cpu 36.020 total

stillinbeta avatar Oct 09 '18 20:10 stillinbeta

Just tested and it works for me:

provider "digitalocean" {}

resource "digitalocean_floating_ip" "ip" {
  region = "nyc1"
  droplet_id = "${digitalocean_droplet.droplet.id}"
}

resource "digitalocean_droplet" "droplet" {
  name = "mastodon"
  image = "ubuntu-18-04-x64"
  region = "nyc1"
  size = "1gb"
}

Output:

digitalocean_droplet.droplet: Creation complete after 2m4s
digitalocean_floating_ip.ip: Creating...
digitalocean_floating_ip.ip: Still creating... (10s elapsed)
digitalocean_floating_ip.ip: Creation complete after 19s

Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

ArtiomL avatar Oct 09 '18 20:10 ArtiomL

I tried this again on my macbook and on a x86 linux cloud instance, and it worked in both places. My guess, therefore, is that somehow this is an ARM-specific bug. Unless you have an ARM machine, I'm probably on my own to fix this.

stillinbeta avatar Oct 10 '18 13:10 stillinbeta

Thanks for that additional info on the platform. My suspicion that the Action.resource_id is larger than what fits in an int on your platform. If that's the case, this would need to be solved in github.com/digitalocean/godo

andrewsomething avatar Oct 10 '18 14:10 andrewsomething

@stillinbeta I just tested with version 1.0.0 and 1.0.2 on my Raspberry Pi 3 and am unable to reproduce.

I'm wondering if Andrew is right in the specific int id is too large? Not sure where to go with this one.

eddiezane avatar Oct 17 '18 14:10 eddiezane

While running on my ARM platform i encountered the same issue. The issue is not apparent on my x86 workstation.

martinaamodt avatar Jul 09 '20 08:07 martinaamodt

Same issue on Windows. After checking the Terraform binary, it seems I somehow installed the 32 bits version, was solved after using 64 bits.

bramd avatar Aug 24 '20 21:08 bramd

my arm laptop is 32 bits, so that's probably the throughline.

stillinbeta avatar Aug 25 '20 02:08 stillinbeta

@stillinbeta @martinaamodt did switching to the 64 bit arm binary solve this?

eddiezane avatar Sep 03 '20 16:09 eddiezane