mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 06:27:05 +00:00
Merge pull request #36990 from bboreham/never-hairpin-all-interfaces
Automatic merge from submit-queue (batch tested with PRs 36990, 37494, 38152, 37561, 38136) Never set hairpin mode on every interface <!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, read our contributor guidelines https://github.com/kubernetes/kubernetes/blob/master/CONTRIBUTING.md and developer guide https://github.com/kubernetes/kubernetes/blob/master/docs/devel/development.md 2. If you want *faster* PR reviews, read how: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/faster_reviews.md 3. Follow the instructions for writing a release note: https://github.com/kubernetes/kubernetes/blob/master/docs/devel/pull-requests.md#release-notes --> **What this PR does / why we need it**: Abandon setting hairpin mode if finding the peer interface fails; simply return an error. There are many reasons why finding the peer could fail - "`ethtool` not installed" is popular. Going ahead and changing the hairpin setting on every bridge-connected interface on the machine may have unwanted effects on other things installed on the machine (e.g. https://github.com/kubernetes/kops/issues/879) **Which issue this PR fixes** : fixes #19766 **Special notes for your reviewer**: **Release note**: <!-- Steps to write your release note: 1. Use the release-note-* labels to set the release note state (if you have access) 2. Enter your extended release note in the below block; leaving it blank means using the PR title as the release note. If no release note is required, just write `NONE`. --> ```release-note Kubelet will no longer set hairpin mode on every interface on the machine when an error occurs in setting up hairpin for a specific interface. ``` /cc @thockin who appears to have requested this implementation at https://github.com/kubernetes/kubernetes/pull/13628#issuecomment-138128180
This commit is contained in:
commit
3c1a8f05d7
@ -58,8 +58,7 @@ func setUpContainerInternal(containerInterfaceName, containerDesc string, nsente
|
||||
e := exec.New()
|
||||
hostIfName, err := findPairInterfaceOfContainerInterface(e, containerInterfaceName, containerDesc, nsenterArgs)
|
||||
if err != nil {
|
||||
glog.Infof("Unable to find pair interface, setting up all interfaces: %v", err)
|
||||
return setUpAllInterfaces()
|
||||
return err
|
||||
}
|
||||
return setUpInterface(hostIfName)
|
||||
}
|
||||
@ -95,17 +94,6 @@ func findPairInterfaceOfContainerInterface(e exec.Interface, containerInterfaceN
|
||||
return iface.Name, nil
|
||||
}
|
||||
|
||||
func setUpAllInterfaces() error {
|
||||
interfaces, err := net.Interfaces()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, netIf := range interfaces {
|
||||
setUpInterface(netIf.Name) // ignore errors
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setUpInterface(ifName string) error {
|
||||
glog.V(3).Infof("Enabling hairpin on interface %s", ifName)
|
||||
ifPath := path.Join(sysfsNetPath, ifName)
|
||||
|
Loading…
Reference in New Issue
Block a user