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

fix service port number lookup to use protocol #1023

Merged
merged 2 commits into from
Oct 4, 2022

Conversation

kjetilho
Copy link
Contributor

@kjetilho kjetilho commented Dec 1, 2021

The existing code passes :proto, which string_to_port casts to a
string, gets "proto", compares that to the possibilities "udp" or "tcp",
and when neither, falls back to using "tcp".

This patch passes the actual proto value to the function, in case there is
a UDP specific service in your /etc/services (uncommon, but it happens).
It looks like Puppet will evaluate the properties in declared order,
so I had to move newproperty(:proto) up so @resource[:proto] was
available in the code for sport, dport and port.

@kjetilho kjetilho requested a review from a team as a code owner December 1, 2021 21:00
@puppet-community-rangefinder
Copy link

firewall is a type

that may have no external impact to Forge modules.

This module is declared in 105 of 578 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@kjetilho
Copy link
Contributor Author

kjetilho commented Dec 1, 2021

Hrm, looks like the test case "'040 partial invert" needs adjustment? It now bombs since "http/udp" does not exist in the test harness (it does exist on my Fedora!). This error was hidden earlier since it looked up "http/tcp".

@github-actions
Copy link

This PR has been marked as stale because it has been open for a while and has had no recent activity. If this PR is still important to you please drop a comment below and we will add this to our backlog to complete. Otherwise, it will be closed in 7 days.

@github-actions github-actions bot added the stale label Apr 30, 2022
@kjetilho
Copy link
Contributor Author

kjetilho commented May 1, 2022

This bug is still relevant, and the patch still applies cleanly.

@github-actions github-actions bot removed the stale label May 2, 2022
@LukasAud
Copy link
Contributor

LukasAud commented May 2, 2022

Hi @kjetilho, thanks for letting us know. We are using the stale-bot as a tool to sort our current PRs and figure out which ones are relevant and which ones might be outdated. We will be putting your PR into the active column and, hopefully, we will be able to review it soon. Thanks for your patience.

@LukasAud
Copy link
Contributor

Closing and opening to re-kick automated testing.

@LukasAud LukasAud closed this May 16, 2022
@LukasAud LukasAud reopened this May 16, 2022
@puppet-community-rangefinder
Copy link

firewall is a type

Breaking changes to this file WILL impact these 121 modules (exact match):
Breaking changes to this file MAY impact these 145 modules (near match):

This module is declared in 107 of 579 indexed public Puppetfiles.


These results were generated with Rangefinder, a tool that helps predict the downstream impact of breaking changes to elements used in Puppet modules. You can run this on the command line to get a full report.

Exact matches are those that we can positively identify via namespace and the declaring modules' metadata. Non-namespaced items, such as Puppet 3.x functions, will always be reported as near matches only.

@LukasAud
Copy link
Contributor

Hi @kjetilho, there seems to be a spec test that is failing currently on your PR. The log is pointing at the following file:

rspec ./spec/unit/puppet/provider/iptables_spec.rb:340 # iptables provider when inverting rules fails when not all array items are inverted

Can you investigate this issue and (if related to your PR) make the necessary changes for the test to pass?

@david22swan
Copy link
Member

@kjetilho Any movement on this?

@kjetilho kjetilho force-pushed the fix_string_to_port branch from beea16b to a2cb174 Compare August 17, 2022 15:03
@kjetilho
Copy link
Contributor Author

yep, I can reproduce when testing locally. will fix soon. thanks!

@kjetilho kjetilho force-pushed the fix_string_to_port branch from a2cb174 to 3208d52 Compare August 17, 2022 15:24
@jordanbreen28
Copy link
Contributor

jordanbreen28 commented Oct 3, 2022

@kjetilho Thanks for this - can you rebase with the current main so we can proceed.

The existing code passes `:proto`, which `string_to_port` casts to a
string, gets "proto", compares that to the possibilities "udp" or "tcp",
and when neither, falls back to using "tcp".

This patch passes the actual proto value to the function, in case there is
a UDP specific service in your /etc/services (uncommon, but it happens).
It looks like Puppet will evaluate the properties in declared order,
so I had to move `newproperty(:proto)` up so `@resource[:proto]` was
available in the code for `sport`, `dport` and `port`.
Switch to "talk" (port 517), since that is an UDP only service in the default Debian and RedHat /etc/services.
@kjetilho kjetilho force-pushed the fix_string_to_port branch from 3208d52 to ae64598 Compare October 3, 2022 21:04
@kjetilho
Copy link
Contributor Author

kjetilho commented Oct 3, 2022

not sure if you are notified when I push a rebase, so adding a comment: "sure!" :)

Copy link
Contributor

@jordanbreen28 jordanbreen28 left a comment

Choose a reason for hiding this comment

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

LGTM - test failures unrelated to PR.

@jordanbreen28 jordanbreen28 merged commit fe44d38 into puppetlabs:main Oct 4, 2022
@kjetilho kjetilho deleted the fix_string_to_port branch November 4, 2022 14:55
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.

5 participants