-
Notifications
You must be signed in to change notification settings - Fork 481
Enable sloppy_tcp when DSR and Maglev is enabled #1888
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ type LocalKRNode struct { | |
KRNode | ||
NodeInterfaceName string | ||
linkQ LocalLinkQuerier | ||
sloppyTCP SysctlConfig | ||
} | ||
|
||
// NodeIPAware is an interface that provides methods to get the node's IP addresses in various data structures. | ||
|
@@ -73,9 +74,14 @@ type NodeIPAndFamilyAware interface { | |
NodeFamilyAware | ||
} | ||
|
||
type NodeConfigAware interface { | ||
SloppyTCP() *SysctlConfig | ||
} | ||
|
||
// NodeAware is an interface that combines the NodeIPAware, NodeInterfaceAware, NodeFamilyAware, and NodeNameAware | ||
// interfaces. | ||
type NodeAware interface { | ||
NodeConfigAware | ||
NodeIPAware | ||
NodeInterfaceAware | ||
NodeFamilyAware | ||
|
@@ -127,6 +133,10 @@ func (n *KRNode) GetNodeName() string { | |
return n.NodeName | ||
} | ||
|
||
func (n *LocalKRNode) SloppyTCP() *SysctlConfig { | ||
return &n.sloppyTCP | ||
} | ||
|
||
// FindBestIPv6NodeAddress returns the best available IPv6 address for the node. If the primary IP is already an IPv6 | ||
// address, it will return that. Otherwise, it will return the first internal or external IPv6 address defined in the | ||
// Kubernetes Node Object. | ||
|
@@ -241,6 +251,12 @@ func NewKRNode(node *apiv1.Node, linkQ LocalLinkQuerier, enableIPv4, enableIPv6 | |
}, | ||
linkQ: linkQ, | ||
NodeInterfaceName: nodeInterfaceName, | ||
// Purposefully set the value of sloppyTCP to 0. This ensures the machine's sloppy_tcp setting remains | ||
// unchanged when there are no services with both Maglev and DSR enabled. | ||
sloppyTCP: SysctlConfig{ | ||
name: IPv4IPVSSloppyTCP, | ||
value: 0, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At first I was sceptical about hard-coding this this value, but I think that it makes sense, especially when handling the reverse condition that I asked for above. Essentially assuming that this is Do you mind writing something like that in a comment above this setting so that we remember that we purposefully didn't look up the live setting with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sure I will do. |
||
}, | ||
} | ||
|
||
return krNode, nil | ||
|
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.
We should handle disabling Sloppy TCP in the case that it is enabled and there are no DSR services with maglev hashing found.
Can you add an
else if
here to handle!enableSloppyTCP && sloppyTCP.CachedVal() == 1
? (I think that one of the linters in this project may ask you to change theif ... else if
to aswitch
statement when making this change)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 was thinking about the scenario when an user had already set sloppy_tcp to 1 and if we disable sloppy_tcp then we are going against the user even though kube-router can still function with sloppy_tcp being set.
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 that its a pretty obscure option, so we're probably safe here. And since it potentially makes services less secure, if we set it, then we should unset it if its not needed.
I see what you're saying, but I think that we can probably just explain this a bit by adding something to the documentation saying that we expect to control this option when the service controller is enabled.
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.
okay.
I have updated the code to disable sloppy_tcp if there is no service with DSR or Maglev enabled.