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 ifconfig parse logic failing on some tunnels #2635

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Woellchen
Copy link

Tunnel interfaces that have a line similar to
"tunnel inet 192.0.2.1 --> 192.0.2.2" would fail the network resolver
because IPs were extracted through two separate IP + mask patterns.
However, in the example above, there is no such thing as a netmask.

This fix merges the patterns and extracts the IPs and netmasks
together so that no mismatches can occur. It might also fix some
cases where only the netmask would be nil and therefore produce an
invalid binding that could in turn resolve to the wrong (outer) IP of
the tunnel instead of the inner IP.

@Woellchen Woellchen requested a review from a team as a code owner November 8, 2023 11:53
@puppetlabs-jenkins
Copy link
Collaborator

Can one of the admins verify this patch?

@joshcooper joshcooper added the bug Something isn't working label Apr 11, 2024
Copy link
Contributor

@joshcooper joshcooper left a comment

Choose a reason for hiding this comment

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

Thanks @Woellchen! In the first commit that demonstrates the failure, can you mark the failing test(s) as pending? And then remove the pending in the second commit. This is important so that each commit passes if we later need to git bisect.

Or you can keep the commits as-is and I can squash them when merging. Let me know which sounds better.

Tunnel interfaces that have a line similar to
"tunnel inet 192.0.2.1 --> 192.0.2.2" would fail the network resolver
because IPs were extracted through two separate IP + mask patterns.
However, in the example above, there is no such thing as a netmask.

This fix merges the patterns and extracts the IPs and netmasks
together so that no mismatches can occur. It might also fix some
cases where only the netmask would be nil and therefore produce an
invalid binding that could in turn resolve to the wrong (outer) IP of
the tunnel instead of the inner IP.
@Woellchen Woellchen force-pushed the fix/main/fix_ifconfig_tunnel_parsing branch from 4c6519c to a83e1f9 Compare April 17, 2024 09:10
@Woellchen
Copy link
Author

Hey @joshcooper, thanks for getting back to me!
I see your point and I have marked the tests as pending in the first commit, and unmarked them in the following one.
Please check one more time if this looks good to you now :)

@@ -5,6 +5,10 @@

let(:log_spy) { instance_spy(Facter::Log) }

before do
pending 'contains failing tests to reproduce a bug'
Copy link
Contributor

Choose a reason for hiding this comment

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

This will cause all passing tests to fail, because they're "no longer" pending. See https://rspec.info/features/3-12/rspec-core/pending-and-skipped-examples/pending-examples/

You'll want to move the call to pending to the specific tests that aren't working yet (instead of callling raise in the test) like:

 it 'returns dhcp server ip as nil' do
  pending('not working yet')
  expect(networking.resolve(:dhcp)).to be(nil)
end

Copy link
Author

Choose a reason for hiding this comment

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

Hey @joshcooper! I have put the pending call on purpose in the before clause because all tests are actually failing with the updated ifconfig fixture to demonstrate that it really breaks Facter.
To not put the pending call in each and every test case I have moved it to before, but for that reason I also had to temporarily add the raises in these two tests to make rake spec succeed.
In the following commit I revert the pending and raises. Do you want me to move the pending call to every test case instead?

@joshcooper
Copy link
Contributor

Closing and reopening to trigger the right set of checks

@joshcooper joshcooper closed this Jul 26, 2024
@joshcooper joshcooper reopened this Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants