-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Add network teaming support (and clean up bond support) for RHEL/CentOS #57775
Conversation
This makes the following changes: 1. Network teaming support added via two new interface types: `team` and `teamport`. 2. Bond support cleaned up significantly. A lot of code was duplicated in the functions that build bonding opts for the various bonding modes. This duplicated code now resides in helper functions. In addition, for the bonding types that have required configuration parameters, the error messages now actually make sense and lead you to what is missing. 3. Fix shadowing of `type` in `network.managed` state by pulling it out of the kwargs. In addition, `type` now defaults to `eth` if no type is provided. If you just want to disable an interface, you shouldn't be required to also include an interface type. 4. Documentation for the `network.managed` state has been completely overhauled, with explanations for the different interface types, instead of just one large code-block with example states and zero explanation/context. 5. Various weirdness introduced by blackening of the codebase has been cleaned up. 6. Interface templates for EL5 and EL6 removed, as Salt is no longer supported on these platforms. 7. Usage of six has been retired, as it is no longer needed. 8. Unit tests for each bond mode, as well as the new team/teamport interfaces types, have been added.
Hahahahaha. I just pushed #57776 which is adding teaming support. 🤦🏻♂️ Small thing I noticed though on your change: you're using DEVICETYPE as well, which is sensible for better compatibility. |
@ixs Haha, great timing! 😆 The reason that I am using both I did not consider trying to leave out |
Have a look at https://unix.stackexchange.com/a/157252 which explains what is going on better than I could. When you use DEVICETYPE, TYPE should be omitted to prevent the wrong scripts from running. On another note: I noticed you're deleting the rh5 and rh6 templates. Sure that's a good idea? That would mean no support for managing network interfaces on those OS releases. rhel5 might make sense but rhel6 is still supported by RH for at least half a year. I do not believe we should be breaking that. |
OK, I will get this changed on Wednesday.
As noted in the OP, Salt version 3001 does not support EL6 (actually now that I look, I did not specifically mention 3001), so there is no point in keeping these templates.
It looks like the references there were a bit out-of-date, and should reflect newer Fedora using an |
Okay, I had a quick look at the code, teaming support looks good. You solved it basically the same way I did with the only difference that I did a |tojson in the template and you do json.dumps() in the module. 😂 There's only one small issue at the hwaddr/addr_auto step where it should only do this for the team master and not for the team members. Did not review the bonding code as I do not use it. |
@ixs Can you have another look when you get a moment? |
@ixs I saw your review comment but it seems to be gone now. I'm working on a change to address that. |
OK, just pushed a change to warn when "addr" is used to set the interface's hwaddr. I checked the other |
I wouldn't worry about addr. I deleted it when I noticed that nobody ever used addr and every sls uses hwaddr. |
Ah, OK... well, probably still doesn't hurt to have the warning there. |
@ixs Thanks a lot for your help! |
Did have another look. Looks good. I initially thought the addr -> hwaddr change would break existing SLS files, but I was mistaken. The team change looks good, DEVICETYPE being a general thing now is good, the hwaddr logic fix looks good. RHEL4 was the last OS where the bonding options go into the modprobe.d config file. Since RHEL5 there's a ifcfg file parameter called BONDING_OPTS that gets all the kernel config parameters. Which saltstack already supports.
Otherwise I'll have a closer look at the bonding changes. Quick glance looks good, but I need to read closer to get the logic right. |
Ohh, another note. It might make sense for you to review #57772 and land that in master before applying your change. That's a one line fix for a KeyError cascade in rh_ip. Spotted that yesterday while doing my work for teaming. |
These are redundant and no longer necessary. The `network.managed` state has been modified to only try to build modprobe configurations if the functions to do so exist, allowing other platforms to continue to work as before.
@ixs You're right about I also pulled in your fix from #57772, and I added a release notes file for the upcoming version 3002 which mentions the function removal as well as the new network teaming support. |
Nice. Looks good. Of course, now my commit stats to salt look so much worse. 😂 I'm gonna have a look over the current change in a bit with a focus on the reworked bonding now. |
Haha, sorry! I've been working on this for a few weeks and I did mention it in the community slack's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good. Is it possible to add an integration test in addition to the unit tests for this?
@@ -808,7 +722,7 @@ def _parse_settings_eth(opts, iface_type, enabled, iface): | |||
result["enable_ipv6"] = opts["enable_ipv6"] | |||
|
|||
valid = _CONFIG_TRUE + _CONFIG_FALSE | |||
for opt in [ | |||
for opt in ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why you are changing this from a list to tuple here but in other places are changing these kinds of checks from tuples to lists? Would it be better to standardize on tuples if they don't need to be mutable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think any of my changes involved changing tuples to lists, did I miss anything?
@dwoz I felt that unit tests were better here for a few reasons:
That said, I'm 100% open to adding integration tests, if you have any ideas on what pieces would be feasible to test. |
Wait? you worked on that for a few weeks? Sorry man, I hacked mine up in half an evening. No wonder your's better and has tests. 😀 Anyway, I had a final read over rh_ip.py looking at the bonding stuff. Looks good, tests finish, commit and ship it! |
Well it wasn't the only thing I worked on during that time 😄
One of the core devs streams testing stuff on Twitch, if you have Google Calendar you can add the SaltStack calendar via this link. Mostly I just learned by looking at tests to see what other people already did. Also, this article is a good resource for learning how to use mocking in unit tests.
👍 |
@terminalmage thank you for still to be here! =) |
Just added a changelog file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably also mention Fedora? Or maybe just say RH family of operating systems?
@ixs How does it look now? |
This makes the following changes:
Network teaming support added via two new interface types:
team
andteamport
.Bond support cleaned up significantly. A lot of code was duplicated in the functions that build bonding opts for the various bonding modes. This duplicated code now resides in helper functions. In addition, for the bonding types that have required configuration parameters, the error messages now actually make sense and lead you to what is missing.
Fix shadowing of
type
innetwork.managed
state by pulling it out of the kwargs. In addition,type
now defaults toeth
if no type is provided. If you just want to disable an interface, you shouldn't be required to also include an interface type.Documentation for the
network.managed
state has been completely overhauled, with explanations for the different interface types, instead of just one large code-block with example states and zero explanation/context.Various weirdness introduced by blackening of the codebase has been cleaned up.
Interface templates for EL5 and EL6 removed, as Salt is no longer supported on these platforms.
Usage of six has been retired, as it is no longer needed.
Unit tests for each bond mode, as well as the new team/teamport interface types, have been added.
ip.get_bond
andip.build_bond
removed from rh_ip since no supported release needs them.