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

delete-rule in Firewalls not working #320

Closed
nikolafilipovic opened this issue Apr 30, 2021 · 2 comments
Closed

delete-rule in Firewalls not working #320

nikolafilipovic opened this issue Apr 30, 2021 · 2 comments

Comments

@nikolafilipovic
Copy link

Hi all,

For some reason, I'm unable to delete a rule through CLI for a specified firewall.

Attaching a screenshot that shows the issue I'm running into:
image

For reference, here are the commands I used.

Creating the firewall rule:
hcloud firewall add-rule {{FIREWALL_NAME}} --direction in --protocol tcp --port 22 --source-ips @("1.1.1.1/32")

Deleting the firewall rule:
hcloud firewall delete-rule {{FIREWALL_NAME}} --direction in --protocol tcp --port 22 --source-ips @("1.1.1.1/32")

Am I missing something or did I just come across a bug?

Thanks!

tomsiewert added a commit to tomsiewert/cli that referenced this issue May 13, 2021
As reported in hetznercloud#320, firewall rules can not be deleted because they
would not exist even if they are shown in "firewall describe".
This behaviour was correct because reflect.DeepEqual also compares if a
slice is empty or nil.
The slices DestinationIPs and SourceIPs are empty slices in an existing
firewall rule. However, the temporary FirewallRule object had slices
that were nil.

To fix this problem, the simple solution is to create an empty IPNet slice
for the respective direction (DestinationIPs for the direction "in", and
SourceIPs for the direction "out").
@tomsiewert
Copy link
Member

tomsiewert commented May 13, 2021

I can confirm it is a bug in the validation part.

The existing firewall rules have an empty DestinationIPs slice. For comparison, the CLI creates a temporary firewall object which has a nil-slice for DestinationIPs. The result is a correct behaviour from result.DeepEqual because the slices do not match.

I have opened a PR with a fix (see #324).

tomsiewert added a commit to tomsiewert/cli that referenced this issue May 13, 2021
…ices

As reported in hetznercloud#320, firewall rules can not be deleted because they
would not exist even if they are shown in "firewall describe".
This behaviour was correct because reflect.DeepEqual also compares if a
slice is empty or nil.
The slices DestinationIPs and SourceIPs are empty slices in an existing
firewall rule. However, the temporary FirewallRule object had slices
that were nil.

To fix this problem, the simple solution is to create an empty IPNet slice
for the respective direction (DestinationIPs for the direction "in", and
SourceIPs for the direction "out").

Signed-off-by: Tom Siewert <[email protected]>
LKaemmerling pushed a commit that referenced this issue May 17, 2021
…ices (#324)

As reported in #320, firewall rules can not be deleted because they
would not exist even if they are shown in "firewall describe".
This behaviour was correct because reflect.DeepEqual also compares if a
slice is empty or nil.
The slices DestinationIPs and SourceIPs are empty slices in an existing
firewall rule. However, the temporary FirewallRule object had slices
that were nil.

To fix this problem, the simple solution is to create an empty IPNet slice
for the respective direction (DestinationIPs for the direction "in", and
SourceIPs for the direction "out").

Signed-off-by: Tom Siewert <[email protected]>
@LKaemmerling
Copy link
Member

Hey @nikolafilipovic,

thank you for the report. @tomsdevsn fixed it in #324 and the fix will be part of the next release. Therefore I will close the issue.

Thank you!

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

No branches or pull requests

3 participants