Skip to content

Conversation

sidshas03
Copy link

  • Allow omitting ports parameter for TCP/UDP protocols to create rules that encompass all ports
  • Update validation to make ports parameter optional for TCP/UDP protocols
  • Add support for reading rules created without explicit ports
  • Add test case for all-ports functionality
  • Update documentation with example and clarification

Fixes #202

@kiranchavala
Copy link
Collaborator

@sidshas03 Could you please make sure the test pass

@sidshas03
Copy link
Author

@sidshas03 Could you please make sure the test pass

Sure sir. I'm working on it. Sorry for the late reply!

@sidshas03 sidshas03 force-pushed the fix-egress-firewall-all-ports branch from 7d6a79d to e16d5a2 Compare September 17, 2025 15:53
@sidshas03
Copy link
Author

@kiranchavala I’ve pushed updates to support TCP/UDP all-ports when ports are omitted, normalize reads for 0/0, -1/-1, and 1/65535, add an acceptance test, and update the docs. I’m watching CI and will fix anything that fails as soon as the test cases start running. Thanks!

Commit: e16d5a2

@sidshas03
Copy link
Author

Status update:
– Pushed no-op commit Commit ID 987dc7b to retrigger the full acceptance matrix.
– Local make build && make test pass.
– Failures previously looked like simulator start/timeout rather than code.
If the matrix still flakes, I can (a) bump the simulator readiness wait in our composite action, or (b) temporarily narrow acceptance to the egress firewall tests to prove the fix. Happy to push either change.

@kiranchavala
Copy link
Collaborator

Thanks @sidshas03 i see that tests are failing at this point

Screenshot 2025-09-18 at 11 21 48 AM

cc @vishesh92

@sidshas03 sidshas03 mentioned this pull request Sep 18, 2025
2 tasks
@kiranchavala kiranchavala reopened this Sep 22, 2025
@vishesh92 vishesh92 requested a review from Copilot September 23, 2025 10:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables support for all-ports firewall rules in the CloudStack egress firewall resource by making the ports parameter optional for TCP/UDP protocols. When ports are omitted, the provider creates rules that encompass all ports, providing better flexibility for firewall configurations.

  • Allow omitting ports parameter for TCP/UDP protocols to create all-ports rules
  • Add comprehensive test coverage for all-ports functionality including transitions
  • Update documentation with examples demonstrating all-ports usage

Reviewed Changes

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

File Description
cloudstack/resource_cloudstack_egress_firewall.go Core logic to handle all-ports rules creation and reading, with validation changes
cloudstack/resource_cloudstack_egress_firewall_test.go Comprehensive test cases for all-ports functionality and transitions
website/docs/r/egress_firewall.html.markdown Documentation updates with examples and clarification

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


* `ports` - (Optional) List of ports and/or port ranges to allow. This can only
be specified if the protocol is TCP or UDP.
be specified if the protocol is TCP or UDP. For TCP/UDP, omitting `ports` creates an all-ports rule. CloudStack may represent this as empty start/end, `0/0`, or `1/65535`; the provider handles all.
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The sentence structure is unclear and contains a grammatical error. Consider revising to: 'be specified if the protocol is TCP or UDP. For TCP/UDP protocols, omitting ports creates an all-ports rule. CloudStack may represent this as empty start/end ports, 0/0, or 1/65535; the provider handles all formats.'

Suggested change
be specified if the protocol is TCP or UDP. For TCP/UDP, omitting `ports` creates an all-ports rule. CloudStack may represent this as empty start/end, `0/0`, or `1/65535`; the provider handles all.
be specified if the protocol is TCP or UDP. For TCP/UDP protocols, omitting `ports` creates an all-ports rule. CloudStack may represent this as empty start/end ports, `0/0`, or `1/65535`; the provider handles all formats.

Copilot uses AI. Check for mistakes.

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

// treats 'all ports' for tcp/udp across CS versions returning 0/0, -1/-1, or 1/65535
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

The comment has grammatical issues. Consider revising to: '// isAllPortsTCPUDP determines if a rule represents all ports for TCP/UDP protocols across CloudStack versions that may return 0/0, -1/-1, or 1/65535'

Suggested change
// treats 'all ports' for tcp/udp across CS versions returning 0/0, -1/-1, or 1/65535
// isAllPortsTCPUDP determines if a rule represents all ports for TCP/UDP protocols across CloudStack versions that may return 0/0, -1/-1, or 1/65535

Copilot uses AI. Check for mistakes.

Comment on lines +761 to +762
// Note: ports parameter is optional for TCP/UDP protocols
// When omitted, the rule will encompass all ports
Copy link
Preview

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

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

[nitpick] These comments are placed in an odd location within the validation logic. Consider moving them to the function-level documentation or closer to where the actual logic handles the omitted ports case for better code organization.

Copilot uses AI. Check for mistakes.

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.

Unable to create egress rules encompassing all ports without explicitly defining them
2 participants