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]: ipv4_address & ipv6_address on server resource are not updated correctly #688

Open
apricote opened this issue Jun 12, 2023 · 1 comment

Comments

@apricote
Copy link
Member

What happened?

When adding/removing a primary IP through hcloud_server.public_net.ipv4/6_enabled the updated values in hcloud_server.ipv4/6_address are only visible after a second apply.

Bug demoed here: https://asciinema.org/a/9vjHZx6bEq3RoWYTZ1EbftUEu

What did you expect to happen?

Expected the changes to be visible immediatly after adding/removing the address.

Please provide a minimal working example

Can be observed with this config and then toggling the ipv6 address on and off, output should change with a 1 apply "delay":

resource "hcloud_server" "tf_687" {
  server_type = "cax11"
  name = "tf-687"
  image = "ubuntu-22.04"
  location = "fsn1"

  public_net {
    ipv4_enabled = true
    ipv6_enabled = false
  }
}

output "ipv6" {
  value = hcloud_server.tf_687.ipv6_address
}

For easier debugging, these changes to the e2e test also exhibit the broken behaviour:

diff --git a/internal/e2etests/server/resource_test.go b/internal/e2etests/server/resource_test.go
index d6a5934e..02a1edfd 100644
--- a/internal/e2etests/server/resource_test.go
+++ b/internal/e2etests/server/resource_test.go
@@ -605,9 +605,15 @@ func TestServerResource_PrimaryIPNetworkTests(t *testing.T) {
                                        resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "network.#", "1"),
                                        resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "network.0.ip", "10.0.1.5"),
                                        resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "network.0.alias_ips.#", "2"),
+                                       resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv4_address", s.PublicNet.IPv4.IP.String()),
+                                       resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv6_address", s.PublicNet.IPv6.IP.String()+"1"),
                                        testsupport.LiftTCF(func() error {
                                                assert.NotEqual(t, 0, s.PublicNet.IPv4.ID)
                                                assert.NotEqual(t, 0, s.PublicNet.IPv6.ID)
+
+                                               // Make sure that public IPs are actually set
+                                               assert.NotEqual(t, "<nil>", s.PublicNet.IPv4.IP.String())
+                                               assert.NotEqual(t, "<nil>", s.PublicNet.IPv6.IP.String())
                                                return nil
                                        }),
                                ),
@@ -627,6 +633,8 @@ func TestServerResource_PrimaryIPNetworkTests(t *testing.T) {
                                        resource.TestCheckResourceAttr(sResWithoutPublicNet.TFID(), "network.#", "1"),
                                        resource.TestCheckResourceAttr(sResWithoutPublicNet.TFID(), "network.0.ip", "10.0.1.5"),
                                        resource.TestCheckResourceAttr(sResWithoutPublicNet.TFID(), "network.0.alias_ips.#", "2"),
+                                       resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv4_address", "<nil>"),
+                                       resource.TestCheckResourceAttr(sResWithNetAndPublicNet.TFID(), "ipv6_address", "<nil>"),
                                        testsupport.LiftTCF(func() error {
                                                assert.Nil(t, s.PublicNet.IPv4.IP)
                                                assert.Nil(t, s.PublicNet.IPv6.IP)
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

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 Oct 9, 2023
@apricote apricote added pinned and removed stale labels Oct 9, 2023
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

1 participant