Skip to content

Add bypass_vlan_overlap_check parameter to cloudstack_private_gateway - #283

Merged
sudo87 merged 5 commits into
apache:mainfrom
bhouse-nexthop:feature/private-gateway-bypass-vlan-overlap-check
Aug 17, 2026
Merged

Add bypass_vlan_overlap_check parameter to cloudstack_private_gateway #283
sudo87 merged 5 commits into
apache:mainfrom
bhouse-nexthop:feature/private-gateway-bypass-vlan-overlap-check

Conversation

@bhouse-nexthop

@bhouse-nexthop bhouse-nexthop commented Mar 6, 2026

Copy link
Copy Markdown
Collaborator
  • Add bypass_vlan_overlap_check optional parameter (defaults to false)
  • Parameter allows bypassing VLAN overlap checks during gateway creation
  • Update resource creation logic to pass parameter to CloudStack API
  • Add comprehensive test coverage:
    • Test with bypass enabled
    • Test default value (false)
    • Update import test to ignore field (not returned by API)
  • Update documentation with examples and parameter description
  • All acceptance tests passing (4/4)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds support for an optional bypassvlanoverlapcheck flag on cloudstack_private_gateway, enabling callers to bypass CloudStack’s VLAN overlap validation at creation time.

Changes:

  • Documented the new bypassvlanoverlapcheck argument and added an HCL example.
  • Extended the private gateway resource schema and create logic to pass the flag to the CloudStack API.
  • Added/updated acceptance tests to cover explicit true, default false, and import behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
cloudstack/resource_cloudstack_private_gateway.go Adds schema field and wires it into the Create API call.
cloudstack/resource_cloudstack_private_gateway_test.go Adds acceptance tests and updates import verification to ignore the new field.
website/docs/r/private_gateway.html.markdown Documents the new argument and provides an example configuration.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cloudstack/resource_cloudstack_private_gateway.go Outdated
Comment thread website/docs/r/private_gateway.html.markdown Outdated
@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

@vishesh92 code review comments addressed, please re-request from copilot

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cloudstack/resource_cloudstack_private_gateway.go Outdated

@vishesh92 vishesh92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

clgtm. didn't test.

@bhouse-nexthop bhouse-nexthop changed the title Add bypassvlanoverlapcheck parameter to cloudstack_private_gateway Add bypass_vlan_overlap_check parameter to cloudstack_private_gateway Mar 11, 2026

@vishesh92 vishesh92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

clgtm. didn't test.

…source

- Add bypassvlanoverlapcheck optional parameter (defaults to false)
- Parameter allows bypassing VLAN overlap checks during gateway creation
- Update resource creation logic to pass parameter to CloudStack API
- Add comprehensive test coverage:
  - Test with bypass enabled
  - Test default value (false)
  - Update import test to ignore field (not returned by API)
- Update documentation with examples and parameter description
- All acceptance tests passing (4/4)
… consistency

The parameter name has been changed from camelCase (bypassvlanoverlapcheck)
to snake_case (bypass_vlan_overlap_check) to maintain consistency with other
resource arguments like ip_address, physical_network_id, and acl_id.

This change affects:
- Resource schema definition
- Resource creation logic
- Test cases and assertions
- Documentation examples

The parameter is now also marked as ForceNew since it can only be set during
gateway creation and cannot be modified afterwards.
@bhouse-nexthop
bhouse-nexthop force-pushed the feature/private-gateway-bypass-vlan-overlap-check branch from a5a909c to 2ae48f0 Compare April 15, 2026 13:43
@vishesh92

Copy link
Copy Markdown
Member

@bhouse-nexthop I found a bug.

  1. apply the terraform
resource "cloudstack_private_gateway" "bar" {
  gateway = "10.1.1.254"
  ip_address = "192.168.0.2"
  netmask = "255.255.255.0"
  vlan = "2"
  vpc_id = cloudstack_vpc.bar.id
  acl_id = cloudstack_network_acl.bar.id
  bypass_vlan_overlap_check = true
  depends_on = ["cloudstack_vpc.bar","cloudstack_network_acl.bar"]
}
  1. Change value of bypass_vlan_overlap_check = true to false and apply again.
  Enter a value: yes

cloudstack_private_gateway.bar: Modifying... [id=01811bb0-ed14-441b-a65e-3a0ce9e218fc]
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵

Stack trace from the terraform-provider-cloudstack plugin:

panic: interface conversion: interface {} is nil, not string

goroutine 82 [running]:
github.com/terraform-providers/terraform-provider-cloudstack/cloudstack.resourceCloudStackNetworkRead(0xc0005aea80, {0x14599a0?, 0xc0004faa08})
        /home/vishesh/lab/apache/cloudstack-terraform-provider/cloudstack/resource_cloudstack_network.go:289 +0xb25
github.com/terraform-providers/terraform-provider-cloudstack/cloudstack.resourceCloudStackPrivateGatewayUpdate(0xc0005aea80, {0x14599a0, 0xc0004faa08})
        /home/vishesh/lab/apache/cloudstack-terraform-provider/cloudstack/resource_cloudstack_private_gateway.go:183 +0x25f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).update(0x178e0d8?, {0x178e0d8?, 0xc0003e9a40?}, 0xd?, {0x14599a0?, 0xc0004faa08?})
        /home/vishesh/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:800 +0x15f
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0003117a0, {0x178e0d8, 0xc0003e9a40}, 0xc0004b2410, 0xc0005ae900, {0x14599a0, 0xc0004faa08})
        /home/vishesh/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/resource.go:919 +0x81a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000013740, {0x178e0d8?, 0xc0003e98c0?}, 0xc000146460)
        /home/vishesh/go/pkg/mod/github.com/hashicorp/terraform-plugin-sdk/v2@v2.33.0/helper/schema/grpc_provider.go:1078 +0xd5c
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x1799050?, 0xc000013740?}}, {0x178e0d8, 0xc0003e98c0}, 0x0?)
        /home/vishesh/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:38 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0xc0002858f0, {0x178e0d8?, 0xc0003e95f0?}, 0xc000146410)
        /home/vishesh/go/pkg/mod/github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc00027f7c0, {0x178e0d8?, 0xc0003e8c00?}, 0xc00023c0e0)
        /home/vishesh/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov6/tf6server/server.go:865 +0x3bc
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x14fc080, 0xc00027f7c0}, {0x178e0d8, 0xc0003e8c00}, 0xc0005ae000, 0x0)
        /home/vishesh/go/pkg/mod/github.com/hashicorp/terraform-plugin-go@v0.24.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:545 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc0001c0e00, {0x178e0d8, 0xc0003e8b70}, {0x1795040, 0xc0004f2000}, 0xc0005aa000, 0xc0003e8870, 0x2199858, 0x0)
        /home/vishesh/go/pkg/mod/google.golang.org/grpc@v1.66.2/server.go:1394 +0xe2b
google.golang.org/grpc.(*Server).handleStream(0xc0001c0e00, {0x1795040, 0xc0004f2000}, 0xc0005aa000)
        /home/vishesh/go/pkg/mod/google.golang.org/grpc@v1.66.2/server.go:1805 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
        /home/vishesh/go/pkg/mod/google.golang.org/grpc@v1.66.2/server.go:1029 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 37
        /home/vishesh/go/pkg/mod/google.golang.org/grpc@v1.66.2/server.go:1040 +0x125

Error: The terraform-provider-cloudstack plugin crashed!

@sureshanaparti

Copy link
Copy Markdown
Contributor

Hi @bhouse-nexthop Can you check the outstanding comments here. Thanks.

resourceCloudStackPrivateGatewayUpdate called resourceCloudStackNetworkRead
instead of resourceCloudStackPrivateGatewayRead. The network read does
d.Get("project").(string), but the private gateway resource has no
"project" attribute, so the type assertion panicked (interface {} is nil,
not string) on any update (e.g. changing acl_id or bypass_vlan_overlap_check).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@bhouse-nexthop

Copy link
Copy Markdown
Collaborator Author

@vishesh92 @sureshanaparti thanks for the report and the ping — fixed in 46a69f6.

Root cause: resourceCloudStackPrivateGatewayUpdate was calling resourceCloudStackNetworkRead instead of resourceCloudStackPrivateGatewayRead. The network read does d.Get("project").(string), but the private gateway resource has no project attribute, so the type assertion panicked (interface {} is nil, not string). This affected any update path (changing acl_id would hit it too), not just bypass_vlan_overlap_check. It now refreshes via the private gateway's own read function, so the true→false change applies cleanly. PTAL.

…ay-bypass-vlan-overlap-check

# Conflicts:
#	website/docs/r/private_gateway.html.markdown
@kiranchavala

Copy link
Copy Markdown
Member

@sureshanaparti @sudo87

Take a call for as #166 solves the same issue

Pick one pr #283 or #166

@sureshanaparti

sureshanaparti commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

@kiranchavala PR #166 covers 'bypass_vlan_check' for network and private gateway, here it is 'bypass_vlan_overlap_check' and is covered for private gateway only. cc @sudo87 @vishesh92

@kiranchavala kiranchavala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM tested manually

Image
resource "cloudstack_private_gateway" "with_bypass" {
  gateway                   = "10.0.0.1"
  ip_address                = "10.0.0.2"
  netmask                   = "255.255.255.252"
  vlan                      = "200"
  vpc_id                    = "cfa1c8b3-2891-4273-ab79-5e1ee6024937"
  acl_id                    = "6b0d728b-6648-11f1-afab-bc2411acabdc"
  bypass_vlan_overlap_check = true
}

terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
  + create

Terraform will perform the following actions:

  # cloudstack_private_gateway.with_bypass will be created
  + resource "cloudstack_private_gateway" "with_bypass" {
      + acl_id                    = "6b0d728b-6648-11f1-afab-bc2411acabdc"
      + bypass_vlan_overlap_check = true
      + gateway                   = "10.0.0.1"
      + id                        = (known after apply)
      + ip_address                = "10.0.0.2"
      + netmask                   = "255.255.255.252"
      + vlan                      = "200"
      + vpc_id                    = "cfa1c8b3-2891-4273-ab79-5e1ee6024937"
    }

Plan: 1 to add, 0 to change, 0 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

cloudstack_private_gateway.with_bypass: Creating...
cloudstack_private_gateway.with_bypass: Creation complete after 6s [id=d3249d3a-a170-4f6a-b841-77a77f7ff35c]

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

Terraform destroy

terraform destroy 
cloudstack_private_gateway.with_bypass: Refreshing state... [id=d3249d3a-a170-4f6a-b841-77a77f7ff35c]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated
with the following symbols:
  - destroy

Terraform will perform the following actions:

  # cloudstack_private_gateway.with_bypass will be destroyed
  - resource "cloudstack_private_gateway" "with_bypass" {
      - acl_id                    = "6b0d728b-6648-11f1-afab-bc2411acabdc" -> null
      - bypass_vlan_overlap_check = true -> null
      - gateway                   = "10.0.0.1" -> null
      - id                        = "d3249d3a-a170-4f6a-b841-77a77f7ff35c" -> null
      - ip_address                = "10.0.0.2" -> null
      - netmask                   = "255.255.255.252" -> null
      - vlan                      = "200" -> null
      - vpc_id                    = "cfa1c8b3-2891-4273-ab79-5e1ee6024937" -> null
    }

Plan: 0 to add, 0 to change, 1 to destroy.

Do you really want to destroy all resources?
  Terraform will destroy all your managed infrastructure, as shown above.
  There is no undo. Only 'yes' will be accepted to confirm.

  Enter a value: yes

cloudstack_private_gateway.with_bypass: Destroying... [id=d3249d3a-a170-4f6a-b841-77a77f7ff35c]
cloudstack_private_gateway.with_bypass: Destruction complete after 3s

Destroy complete! Resources: 1 destroyed.

@sudo87
sudo87 merged commit bd26c49 into apache:main Aug 17, 2026
16 checks passed
@sudo87

sudo87 commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

thank you @kiranchavala

sudo87 added a commit to Longsight/cloudstack-terraform-provider that referenced this pull request Aug 17, 2026
…import test

The merge with main pulled in bypass_vlan_overlap_check (added separately in
apache#283), which duplicates this branch's own bypass_vlan_check field on
cloudstack_private_gateway. Drop the stale duplicate and the overlapping
test resource that relied on it, and ignore bypass_vlan_check on network
import since CloudStack's network API never returns it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants