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

[Bug]: Assigning public IPv4 to an existing server breaks reverse DNS entry #939

Open
cebe opened this issue Jun 14, 2024 · 2 comments
Open
Assignees

Comments

@cebe
Copy link

cebe commented Jun 14, 2024

What happened?

# terraform apply
[...]
  # hcloud_rdns.cloud_ftp_ipv4[0] will be created
  + resource "hcloud_rdns" "cloud_ftp_ipv4" {
      + dns_ptr    = "ftp1.ftp.cloud2.[..]"
      + id         = (known after apply)
      + server_id  = 48738290
        # (1 unchanged attribute hidden)
    }

  # hcloud_rdns.cloud_ftp_ipv6[0] will be created
  + resource "hcloud_rdns" "cloud_ftp_ipv6" {
      + dns_ptr    = "ftp1.ftp.cloud2.[..]"
      + id         = (known after apply)
      + ip_address = "2a01:4f8:[..]"
      + server_id  = 48738290
    }

  # hcloud_server.cloud_ftp[0] will be updated in-place
  ~ resource "hcloud_server" "cloud_ftp" {
        id                         = "48738290"
        name                       = "ftp1.ftp.cloud2.[..]"
        # (22 unchanged attributes hidden)

      - public_net {
          - ipv4         = 0 -> null
          - ipv4_enabled = false -> null
          - ipv6         = 0 -> null
          - ipv6_enabled = true -> null
        }
      + public_net {
          + ipv4         = (known after apply)
          + ipv4_enabled = true
          + ipv6         = (known after apply)
          + ipv6_enabled = true
        }

        # (1 unchanged block hidden)
    }

[...]
Plan: 3 to add, 3 to change, 1 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes
[...]
hcloud_server.cloud_ftp[0]: Modifying... [id=48738290]
hcloud_server.cloud_ftp[0]: Still modifying... [id=48738290, 10s elapsed]
hcloud_server.cloud_ftp[0]: Modifications complete after 16s [id=48738290]
hcloud_rdns.cloud_ftp_ipv6[0]: Creating...
hcloud_rdns.cloud_ftp_ipv6[0]: Creation complete after 2s [id=s-48738290-2a01:4f8:c17:62bf::1]
╷
│ Error: Provider produced inconsistent final plan
│ 
│ When expanding the plan for hcloud_rdns.cloud_ftp_ipv4[0] to include new values learned so far during apply, provider "registry.terraform.io/hetznercloud/hcloud" produced an invalid new value for .ip_address: was cty.StringVal(""), but now cty.StringVal("157.90.248.65").
│ 
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵

What did you expect to happen?

I expect the new IPv4 added and the reverse DNS entry to be updated without error.

Please provide a minimal working example

terraform {
  required_providers {
    hcloud = {
      source  = "hetznercloud/hcloud"
      version = "1.47.0"
    }
  }
  required_version = ">= 1.0.0"
}

provider "hcloud" {
  token = "Neo8FwsD6w2aEM1...N9U"
}

# use SSH key from home dir
resource "hcloud_ssh_key" "instance-ssh-key" {
  name       = "instance-ssh-key"
  public_key = file("~/.ssh/id_rsa.pub")
}

resource "hcloud_server" "cloud_ftp" {
  count = 1

  name        = "ftp${count.index + 1}.ftp.example.com"
  image       = "debian-12"
  server_type = "cax21"
  location    = "hel1"
  ssh_keys    = [hcloud_ssh_key.instance-ssh-key.id]
  # in case of upgrade, keep disk size to allow downgrade later
  keep_disk   = true
  public_net {
    ipv4_enabled = false
#    ipv4_enabled = true
    ipv6_enabled = true
  }
  depends_on = [
    hcloud_ssh_key.instance-ssh-key
  ]
}

resource "hcloud_rdns" "cloud_ftp_ipv6" {
  count = 1
  #  for = toset(range(0, var.k8s_cluster_nodes - 1))
  server_id  = hcloud_server.cloud_ftp[count.index].id
  ip_address = hcloud_server.cloud_ftp[count.index].ipv6_address
  dns_ptr    = hcloud_server.cloud_ftp[count.index].name
}

#resource "hcloud_rdns" "cloud_ftp_ipv4" {
#  count = 1
#  #  for = toset(range(0, var.k8s_cluster_nodes - 1))
#  server_id  = hcloud_server.cloud_ftp[count.index].id
#  ip_address = hcloud_server.cloud_ftp[count.index].ipv4_address
#  dns_ptr    = hcloud_server.cloud_ftp[count.index].name
#}

steps to reproduce:

  1. create file with the content above in an empty directory, enter your hetzner cloud api key
  2. terraform init
  3. terraform apply
  4. set ipv4_enabled = true in servers public_net
  5. uncomment resource "hcloud_rdns"
  6. terraform apply
@cebe cebe added the bug label Jun 14, 2024
@cebe
Copy link
Author

cebe commented Jun 14, 2024

Workaround: Running terraform apply again, makes the correct changes.

@jooola jooola self-assigned this Aug 23, 2024
Copy link

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the stale label Nov 21, 2024
@apricote apricote added pinned and removed stale labels Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants