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 #16935 - Allow a : or . in device ID if there isnt already one set #3942

Closed
wants to merge 1 commit into from

Conversation

sean797
Copy link
Member

@sean797 sean797 commented Oct 14, 2016

No description provided.

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • length of the first commit message line for c2bd57f exceeds 65 characters

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@theforeman-bot
Copy link
Member

There were the following issues with the commit message:

  • length of the first commit message line for 6e576af exceeds 65 characters

If you don't have a ticket number, please create an issue in Redmine, selecting the appropriate project.

More guidelines are available in Coding Standards or on the Foreman wiki.


This message was auto-generated by Foreman's prprocessor

@ares
Copy link
Member

ares commented Oct 17, 2016

looks good to me, could you please add a test to test/models/nics/managed_test.rb? there are already some for the same method

@@ -74,9 +74,11 @@ def identifier_change
old_value = self.identifier_was || ''
Copy link
Contributor

Choose a reason for hiding this comment

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

Note there is a comment on line 71 stating that a change to/from virtual/physical is disallowed, but this should be updated to state that you're now permitting a change from physical to virtual (but you're not allowing virtual to physical, for whatever reason.)

Copy link
Member Author

@sean797 sean797 Oct 17, 2016

Choose a reason for hiding this comment

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

The reason behind this is s390x machines issues dynamic MAC addresses on boot (so I'm told) to configure s390x NIC's via kickstart on the network line/s you need to use --device=<device ID> e.g --device="enccw0.0.1234" (s390x device names have periods in). I ran into this problem where I couldn't add a device ID to a NIC without deleting and adding it again.

I wouldn't say your are changing a device type if you never specified it in the first place?

The good news is to fully support s390x provisioning via kickstart it looks like we just need to make some template changes and a few changes to the host form validation.

Copy link
Member

Choose a reason for hiding this comment

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

@sean797 the problem is that interface is considered physical if identifier is not set. I tend to agree that until it's set, we can't reliably say what kind of interface it is. For interfaces imported from puppet we always have the identifier from facts so this should be safe.

But based on what you say, the problem is that we consider all interfaces with dots in name as virtual which is not true on s390x. So I wonder if we shouldn't rather consider enccw.* as physical interfaces. I'm not sure if all s390x identifiers start with this prefix though.

Copy link
Member Author

@sean797 sean797 Oct 18, 2016

Choose a reason for hiding this comment

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

@ares el7 uses names like the ones in systemd/systemd@e0d4a0a recent Fedora has ones like systemd/systemd@0037a66

So in recent Fedora enccw0.0.0600 becomes enc600 (solving our problem). I also don't really like treating it differently if the name is prefixed with something, but I'm not really sure what to suggest.

Copy link
Member Author

Choose a reason for hiding this comment

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

To be honest this change doesn't really have anything to do with s390x support, i just happened to run into this problem when provisioning s390x. Like @ares says "I tend to agree that until it's set, we can't reliably say what kind of interface it is.", I think we should allow changing interface type, if it's not already set?

Copy link
Member

Choose a reason for hiding this comment

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

I can't find a scenario where this would break. Interfaces have empty identifier only when they are built in Foreman and if it causes problems in some cases, user can set identifiers explicitly. So 👍 from me. Test looks good, I'll give it few tests and if everything is alright and no one objects I'll merge.

@sean797
Copy link
Member Author

sean797 commented Oct 17, 2016

Test added :-)

@lzap
Copy link
Member

lzap commented Oct 19, 2016

I'd also add @ to the list, NetworkManager configures bonds as bond0@eth0 by default. (Or maybe it was VLAN, but I am sure about the character.)

@ares
Copy link
Member

ares commented Oct 20, 2016

@lzap are you sure that facter reports interface like this or is it only output of ip comamnd?

@lzap
Copy link
Member

lzap commented Oct 25, 2016

This was ip command output, I can't tell. Ignore then.

@ares
Copy link
Member

ares commented Oct 26, 2016

One thing that appeared during testing is that we do not reflect the change in "Virtual NIC" checkbox. Imagine I create a new interface without identifier leaving "Virtual NIC" unchecked. Then I change its identifier to "eth0:0", I can't change the checkbox since it's disabled for existing records. On the other hand it seems we use this attribute everywhere so if identifier is changed later it should not do any harm. It's just slightly confusing that eth0:0 would be still considered physical.

Bottom line, if others don't mind the conflict described above, I think we could go further and remove the identifier_change validation completely.

@sean797
Copy link
Member Author

sean797 commented Oct 28, 2016

@ares maybe we should just validate that if "Virtual NIC" checkbox is ticked it has a : or . in the identifier and remove the identifier_change validation?

@ares
Copy link
Member

ares commented Oct 31, 2016

@sean797 maybe even further, just remove the validation. Both vlans and aliases can have custom name. If user changes "eth0.5" to "vlan0" it's fine as long as the checkbox remains ticked. Since we keep the checkbox disabled for persisted interfaces, it should be safe. The only place where we use identifier to determine type I'm aware of is Interface#alias? method. So users should keep : in aliases identifiers. What do you think?

@sean797
Copy link
Member Author

sean797 commented Oct 31, 2016

Agreed :-) Updated!

@dLobatog
Copy link
Member

dLobatog commented Nov 9, 2016

@ares You're right that we're safe because of the checkbox disabled for persisted interfaces. However, I'm not very convinced it should be removed. The reason you added this check in the first place is to avoid a bug where:

  1. User has duplicate interfaces for some reason, e.g: populate_fields_from_facts in app/models/host/managed.rb disables validations.
  2. User now is unable to edit the host because of the uniqueness interface requirement. User is also unable to remove one of the duplicate interfaces.
  3. User is 😞

Maybe I'm missing something and I definitely have not tried it but it seems to me that's a possible bug that can happen - and users hit it before the validation was introduced

@ares
Copy link
Member

ares commented Nov 21, 2016

the reason you added this check in the first place is to avoid a bug where:

@dLobatog I don't think this was the reason. Duplicated interfaces usually came from fact uploads which used to skip validations. It's not the case anymore, invalid interface is not saved and errors are logged only. Also users should be able to delete duplicated interfaces now, there were couple of fixes.

@ares
Copy link
Member

ares commented Nov 21, 2016

Works fine, I'm setting RfM and wait a while to give Daniel and others chance to comment.

@ares
Copy link
Member

ares commented Nov 25, 2016

Thanks @sean797, merged as 16cbc5c.

@ares ares closed this Nov 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants