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

Fixes #36508 - Fix virtual nic configuration in preseed #9735

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

nadjaheitmann
Copy link
Contributor

@nadjaheitmann nadjaheitmann commented Jun 15, 2023

@theforeman-bot
Copy link
Member

Issues: #36508

Copy link
Contributor

@sbernhard sbernhard left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

I think this is mostly correct, but I still think in theforeman/community-templates#688 (comment) a valid point is raised.

We have on line 48 some code that looks up the real interface name (based on the mac address). Is that not something we should still do? Or at least take into account?

The reason we have that is to rely less on the actual identifier and more on the mac address to identify an interface. With the udev stable interface names they may be different from what users expect, or they may not care as much. Whether this assertion still holds is another, but I fear we may end up with a mismatch if we only partially implement it.

I can also see the logic should be something like:

<% if interface.virtual? -%>
real=`ip -o link | awk '/<%= interface.attached_to.mac -%>/ {print $2;}' | sed s/:$//`
<% else -%>
real=`ip -o link | awk '/<%= interface.mac -%>/ {print $2;}' | sed s/:$//`
<% end -%>

Now this probably won't work because attached_to isn't a foreign key, but I hope it shows the concept.

And if anything else, I'd prefer this to be written at least more minimal to show the flow:

<% if interface.virtual? -%>
real="<%= interface.attached_to -%>"
<% else -%>
real=`ip -o link | awk '/<%= interface.mac -%>/ {print $2;}' | sed s/:$//`
<% end -%>

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

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

Untested, but looks good when I read the docs.

@ekohl ekohl merged commit 9df48cc into theforeman:develop Jul 12, 2023
4 checks passed
@nadjaheitmann nadjaheitmann deleted the fix-preseed-virtual-nic branch July 12, 2023 17:07
@@ -45,10 +45,11 @@ EOF
<% interface_subnet6 = interface.subnet6 -%>
<% interface_dhcp6 = interface_subnet6.nil? ? true : interface_subnet6.dhcp_boot_mode? -%>
<% next if !interface.managed? || (interface_subnet.nil? && interface_subnet6.nil?) || interface.primary -%>
real=`ip -o link | awk '/<%= interface.mac -%>/ {print $2;}' | sed s/:$//`
<% virtual = interface.virtual? -%>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ekohl I think I should have removed <% virtual = interface.virtual? -%> as well, not sure why it is still there. Shall I create a fixup?

Copy link
Member

Choose a reason for hiding this comment

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

Oh yes, it could be removed now. Good catch.

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.

4 participants