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

Replacement triggered for docker network with ipam_config #54

Closed
mavogel opened this issue Dec 25, 2020 · 2 comments
Closed

Replacement triggered for docker network with ipam_config #54

mavogel opened this issue Dec 25, 2020 · 2 comments
Labels
bug Something isn't working r/network Relates to the network resource

Comments

@mavogel
Copy link
Contributor

mavogel commented Dec 25, 2020

This issue was originally opened by @project0 as hashicorp/terraform-provider-docker#279. It was migrated here as a result of the community provider takeover from @kreuzwerker. The original body of the issue is below.



I experience strange behavior that it tries to replace my docker network after rebooting the server.
Looks like the ipam_config stanza cannot be properly merged and then triggeres the replacement.

Terraform v0.12.28
+ provider.docker v2.7.1
resource "docker_network" "server" {
  name            = local.network_name
  check_duplicate = true

  driver = "bridge"
  ipv6   = true

  ipam_config {
    subnet = var.subnets.ipv4_cidr
  }

  ipam_config {
    subnet = var.subnets.ipv6_cidr
  }
}
  # module.base.docker_network.server must be replaced
-/+ resource "docker_network" "server" {
      - attachable      = false -> null
        check_duplicate = true
        driver          = "bridge"
      ~ id              = "f565f7f1a0db0c184f69c24e8f113ce7d88c12e43ae4bf862b0f51c15940a633" -> (known after apply)
      - ingress         = false -> null
      ~ internal        = false -> (known after apply)
        ipam_driver     = "default"
        ipv6            = true
        name            = "server-vagrant"
      ~ options         = {} -> (known after apply)
      ~ scope           = "local" -> (known after apply)

      - ipam_config { # forces replacement
          - aux_address = {} -> null
          - gateway     = "172.16.10.1" -> null
          - subnet      = "172.16.10.0/24" -> null
        }
      - ipam_config { # forces replacement
          - aux_address = {} -> null
          - gateway     = "2001:1:6d:99f:400::1" -> null
          - subnet      = "2001:1:006d:099f:0100:0000:0000:0000/80" -> null
        }
      + ipam_config { # forces replacement
          + subnet = "172.16.10.0/24"
        }
      + ipam_config { # forces replacement
          + subnet = "2001:1:006d:099f:0100:0000:0000:0000/80"
        }
    }

docker inspect after creation:

    {
        "Name": "server-vagrant",
        "Id": "7347683ef27d04299465172f017fc89b352e7a1546ba50ec2bd7b3223a9721fa",
        "Created": "2020-07-09T16:53:23.763556354Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": true,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.16.10.0/24"
                },
                {
                    "Subnet": "2001:1:006d:099f:0100:0000:0000:0000/80"
                }
            ]
        }
  }

docker inspect after reboot:

    {
        "Name": "server-vagrant",
        "Id": "f565f7f1a0db0c184f69c24e8f113ce7d88c12e43ae4bf862b0f51c15940a633",
        "Created": "2020-07-06T18:43:47.35749164Z",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": true,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.16.10.0/24",
                    "Gateway": "172.16.10.1"
                },
                {
                    "Subnet": "2001:1:006d:099f:0100:0000:0000:0000/80",
                    "Gateway": "2001:1:6d:99f:100::1"
                }
            ]
        }
}
@mavogel mavogel added bug Something isn't working r/network Relates to the network resource labels Dec 25, 2020
@numin0us
Copy link

I found that specifying the gateway attribute as author mentioned in the previous issue (hashicorp/terraform-provider-docker#279 (comment)) solved this problem for me.

gateway = cidrhost(var.subnets.ipv4_cidr,1)

@mavogel
Copy link
Contributor Author

mavogel commented Jan 12, 2021

Awesome. Thanks for the update. Closing.

@mavogel mavogel closed this as completed Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working r/network Relates to the network resource
Projects
None yet
Development

No branches or pull requests

2 participants