-
Notifications
You must be signed in to change notification settings - Fork 469
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
Refactor: Abstract Node Info #1739
Conversation
This prepares the way for broader refactors in the way that we handle nodes by: * Separating frequently used node logic from the controller creation steps * Keeping reused code DRY-er * Adding interface abstractions for key groups of node data and starting to rely on those more rather than concrete types * Separating node data from the rest of the controller data structure so that it smaller definitions of data can be passed around to functions that need it rather than always passing the entire controller which contains more data / surface area than most functions need.
Refactors are always a bit of a slog to review. But the gist of this one is that instead of storing all of the physical node data as individual data sets like The ultimate goal of this refactor is to stop the need of constantly either attaching functions to the main controllers ( Right now, my mid-term goal is to refactor injectRoute() in order to resolve #1738 in a way that doesn't perpetrate bad coding practices. But eventually I think that more abstractions are going to be needed like this as there is quite a bit of cruft in the code base. |
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.
Had a look at this and left some thoughts in the comments. I think there's one copy-paste error that needs to be addressed, though.
pkg/utils/node.go
Outdated
|
||
// GetNodeIPv4AddrsTypeMap returns the node's IPv4 addresses grouped by Kubernetes Node Object address type (internal / | ||
// external). | ||
func (n *KRNode) GetNodeIPv4AddrsTypeMap() addressMap { |
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.
AFAICT this method and its sibling GetNodeIPv4AddrsTypeMap
aren't used anywhere. Maybe remove them until they're actually needed?
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.
Good catch here as well. It used to be used before I exposed other better functions, then I didn't realize that they were no longer used. I'll remove them.
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.
Thanks @twz123 for the very in-depth code review and excellent suggestions!
pkg/utils/node.go
Outdated
NodeIPv6Addrs addressMap | ||
NodeName string | ||
linkQ LocalLinkQuerier | ||
PrimaryNodeSubnet net.IPNet |
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 think I prematurely added this to the interface because of the usage of utils.GetNodeSubnet(nodeIP, nil)
in network_routes_controller.go
.
You're right, it isn't used anywhere, I'll remove it.
pkg/utils/node.go
Outdated
|
||
// GetNodeIPv4AddrsTypeMap returns the node's IPv4 addresses grouped by Kubernetes Node Object address type (internal / | ||
// external). | ||
func (n *KRNode) GetNodeIPv4AddrsTypeMap() addressMap { |
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.
Good catch here as well. It used to be used before I exposed other better functions, then I didn't realize that they were no longer used. I'll remove them.
Co-authored-by: Tom Wieczorek <[email protected]>
883d2b4
to
f4766d6
Compare
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 good to me
69ed717
to
9e9fb73
Compare
@jnummelin @rbrtbnfgl @mrueg
This prepares the way for broader refactors in the way that we handle nodes by:
Eventually the changes here should better support the work that will need to happen to fix #1738 #676