Repository navigation
fix: create security group rule with any protocol - #3157
pierreprinetti merged 7 commits into
Conversation
There was a problem hiding this comment.
Thank you for submitting your first PR! Be sure that we will be looking at it but keep in mind
this sometimes takes a while.
Please let the maintainers know if your PR has not got enough attention after a few days.
If any doubt, please consult our PR tutorial.
|
I'm afraid that I'm missing something here. What is the problem that this patch is solving? A minimal reproducer in code would be great. /hold |
// ToRuleCreateMap casts a CreateOpts struct to a map.
func (opts CreateOpts) ToRuleCreateMap() (map[string]any, error) {
b, err := gophercloud.BuildRequestBody(opts, "firewall_rule")
if err != nil {
return nil, err
}
if m := b["firewall_rule"].(map[string]any); m["protocol"] == "any" {
m["protocol"] = nil
}
return b, nil
} |
|
There is another issue. When you retrieve the rule, the protocol is a string, and for if sgRule.Protocol == "" {
sgRule.Protocol = string(rules.ProtocolAny)
}Maybe it makes sense to change this directly in gophercloud. see an example terraform-provider-openstack/terraform-provider-openstack#1765 (comment) |
@kayrus Thank you for helping. Done |
|
Terraform supports integer value for the protocol. What if an end user provides "0"? I think we also need to convert it to null. |
I didn't change the value 0. eq |
|
@kmlebedev currently I'm testing corner cases with terraform provider. Just give me some time to post the results of my findings. |
|
@kmlebedev and @HappyFX you both opened a can of worms. It's possible to set the |
|
There is also missing |
|
I know I may sound like a broken record, but... what is the problem that this patch is solving? |
|
After some discussion in #2442, I now believe that the fix here should be to change I think that this patch should really be: diff --git a/openstack/networking/v2/extensions/security/rules/requests.go b/openstack/networking/v2/extensions/security/rules/requests.go
index 78b67b0d..f2ea9f2d 100644
--- a/openstack/networking/v2/extensions/security/rules/requests.go
+++ b/openstack/networking/v2/extensions/security/rules/requests.go
@@ -77,7 +77,7 @@ const (
ProtocolUDP RuleProtocol = "udp"
ProtocolUDPLite RuleProtocol = "udplite"
ProtocolVRRP RuleProtocol = "vrrp"
- ProtocolAny RuleProtocol = "any"
+ ProtocolAny RuleProtocol = ""
)
// CreateOptsBuilder allows extensions to add additional parameters to theWhat do you think? |
|
Or maybe that should be |
Empty looks correct if it will omitted, still neutron API will response as
"0" is act as protocol set with "0x00" HOPOPT - it's will be not expecting filter (not "what ever protocol") security group in openstack. |
|
@kmlebedev Are you OK with changing this PR to be something like this? Would that fit your use-case? |
@pierreprinetti Done |
|
I updated a corresponding terraform-provider-openstack/terraform-provider-openstack#1765 |
kayrus
left a comment
There was a problem hiding this comment.
LGTM, but I'm confused with the semver:major label.
|
Thank you |
|
Failed to backport PR to |
Fixes #2442 after #2309