foreman icon indicating copy to clipboard operation
foreman copied to clipboard

Fixes #36548 - Avoid parsing interfaces with shared MACs

Open ekohl opened this issue 2 years ago • 6 comments

In Azure it is possible to see the same interface share the same MAC address. Foreman wants to identify an interface by its MAC address, and doesn't handle it.

This patch makes parse_interfaces? take duplicate MAC addresses into account and ignores them. While it's not pretty, it at least allows other facts to be imported.

At the moment it's completely untested, but allows me to share the concept easier then describing it.

ekohl avatar Jun 29 '23 11:06 ekohl

Issues: #36548

theforeman-bot avatar Jun 29 '23 11:06 theforeman-bot

@nofaralfasi would you mind reviewing this?

ekohl avatar Jul 22 '24 15:07 ekohl

The tests are failing because in test/static_fixtures/facts/facts_with_certname.json there's a host where the bridge has the same MAC as the interface as well as various VLANs. I think this is fairly common so I'm not sure what to do with this now.

ekohl avatar Jul 30 '24 15:07 ekohl

While going over the original bug I realized that the issue wasn't the duplicate MAC but the duplicate interface names. I'll rewrite the PR.

ekohl avatar Aug 06 '24 11:08 ekohl

I've done some further analysis and I believe my initial impression that the duplicate mac was the problem was correct. Just where it went wrong.

I now thing this is the problem: https://github.com/theforeman/foreman/blob/6aac916fb183f47596e8d543756faac27750a21e/app/models/host/base.rb#L195-L200

We can see in the actual code there's matching by mac address: https://github.com/theforeman/foreman/blob/6aac916fb183f47596e8d543756faac27750a21e/app/models/host/base.rb#L455-L481

That is not correct.

ekohl avatar Aug 06 '24 13:08 ekohl

I pushed some commits that separate it out. @nofaralfasi had a question about the chef fact parser and that's now a separate commit. There's also one that improves docs because I had to understand what was going on.

ekohl avatar Aug 06 '24 13:08 ekohl