Skip to content

make subnet_id in openstack_networking_router_v2 optional#1915

Merged
kayrus merged 2 commits intoterraform-provider-openstack:mainfrom
Hoeze:router_noexternalsubnet
Jul 9, 2025
Merged

make subnet_id in openstack_networking_router_v2 optional#1915
kayrus merged 2 commits intoterraform-provider-openstack:mainfrom
Hoeze:router_noexternalsubnet

Conversation

@Hoeze
Copy link
Copy Markdown
Contributor

@Hoeze Hoeze commented Jun 27, 2025

I want to fix the issue that it is impossible to set only the ip_address without specifying the subnet_id: #922 .

My solution just sets the subnet_id to be computed.
Inspired by #628.

Unfortunately, I do not know what "fixed_ip" I could use in the tests.
Also, I have no idea of how to test this locally with my terraform installation, because terraform strictly refuses to read my self-built binary with "Error: Required plugins are not installed" and some checksum warning.

@kayrus kayrus force-pushed the router_noexternalsubnet branch from ffff3bb to 6b3ed68 Compare July 2, 2025 08:08
@kayrus
Copy link
Copy Markdown
Collaborator

kayrus commented Jul 2, 2025

@Hoeze thanks for the PR. Unfortunately it is not enough to just mark this field as computed. There should be a corresponding gophercloud change to omit empty subnet_id. I'm pushing corresponding changes to test this fix without gophercloud change.

UPD: test results for a new test PASS: TestAccNetworkingV2Router_extIPAddress (2.17s)

2025/07/02 08:20:39 [DEBUG] OpenStack Request URL: POST http://10.1.0.114/networking/v2.0/routers
2025/07/02 08:20:39 [DEBUG] OpenStack Request Headers:
Accept: application/json
Cache-Control: no-cache
Content-Type: application/json
User-Agent: HashiCorp Terraform/1.12.2 (+https://www.terraform.io) Terraform Plugin SDK/dev Terraform Provider OpenStack/dev gophercloud/v2.7.0
X-Auth-Token: ***
2025/07/02 08:20:39 [DEBUG] OpenStack Request Body: {
  "router": {
    "admin_state_up": true,
    "external_gateway_info": {
      "external_fixed_ips": [
        {
          "ip_address": "172.24.4.156"
        }
      ],
      "network_id": "13436772-e75e-48b4-93d5-b9999d4b8da0"
    },
    "name": "router_1"
  }
}
2025/07/02 08:20:40 [DEBUG] OpenStack Response Code: 201
2025/07/02 08:20:40 [DEBUG] OpenStack Response Headers:
Content-Length: 922
Content-Type: application/json
Date: Wed, 02 Jul 2025 08:20:39 GMT
Server: Apache/2.4.52 (Ubuntu)
X-Openstack-Request-Id: req-c14ec30c-3691-4b05-9cad-6fb94a90bbd8
2025/07/02 08:20:40 [DEBUG] OpenStack Response Body: {
  "router": {
    "admin_state_up": true,
    "availability_zone_hints": [],
    "availability_zones": [],
    "created_at": "2025-07-02T08:20:40Z",
    "description": "",
    "enable_default_route_bfd": false,
    "enable_default_route_ecmp": false,
    "external_gateway_info": {
      "enable_snat": true,
      "external_fixed_ips": [
        {
          "ip_address": "172.24.4.156",
          "subnet_id": "f35d9da8-d7f8-4076-9da2-ce108351d6ce"
        }
      ],
      "network_id": "13436772-e75e-48b4-93d5-b9999d4b8da0"
    },
    "external_gateways": [
      {
        "external_fixed_ips": [
          {
            "ip_address": "172.24.4.156",
            "subnet_id": "f35d9da8-d7f8-4076-9da2-ce108351d6ce"
          }
        ],
        "network_id": "13436772-e75e-48b4-93d5-b9999d4b8da0"
      }
    ],
    "flavor_id": null,
    "ha": true,
    "id": "26365987-7494-4f93-adf3-47b9975d49bf",
    "name": "router_1",
    "project_id": "97976e40294b4ed1a6cd3581f759c65e",
    "revision_number": 2,
    "routes": [],
    "status": "ACTIVE",
    "tags": [],
    "tenant_id": "97976e40294b4ed1a6cd3581f759c65e",
    "updated_at": "2025-07-02T08:20:40Z"
  }
}

@Hoeze
Copy link
Copy Markdown
Contributor Author

Hoeze commented Jul 2, 2025

Amazing, thanks a lot for picking this up @kayrus!

@kayrus kayrus force-pushed the router_noexternalsubnet branch from e48dcff to 418e6b3 Compare July 9, 2025 19:56
Copy link
Copy Markdown
Collaborator

@kayrus kayrus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@kayrus kayrus merged commit 3257ac0 into terraform-provider-openstack:main Jul 9, 2025
6 checks passed
@Hoeze
Copy link
Copy Markdown
Contributor Author

Hoeze commented Jul 9, 2025

Thanks a lot @kayrus 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants