improve checking modprob netfilter (#6427)

pull/6435/head
Medya Ghazizadeh 2020-01-29 14:47:23 -08:00 committed by GitHub
parent 541c67d45a
commit e725104e2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 10 deletions

View File

@ -115,13 +115,12 @@ func (k *kicRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
if elapsed > (1 * time.Second) { if elapsed > (1 * time.Second) {
glog.Infof("Done: %v: (%s)", oc.Args, elapsed) glog.Infof("Done: %v: (%s)", oc.Args, elapsed)
} }
} else { return rr, nil
if exitError, ok := err.(*exec.ExitError); ok {
rr.ExitCode = exitError.ExitCode()
}
err = fmt.Errorf("%s: %v\nstdout:\n%s\nstderr:\n%s", rr.Command(), err, rr.Stdout.String(), rr.Stderr.String())
} }
return rr, err if exitError, ok := err.(*exec.ExitError); ok {
rr.ExitCode = exitError.ExitCode()
}
return rr, fmt.Errorf("%s: %v\nstdout:\n%s\nstderr:\n%s", rr.Command(), err, rr.Stdout.String(), rr.Stderr.String())
} }

View File

@ -167,11 +167,14 @@ func disableOthers(me Manager, cr CommandRunner) error {
// enableIPForwarding configures IP forwarding, which is handled normally by Docker // enableIPForwarding configures IP forwarding, which is handled normally by Docker
// Context: https://github.com/kubernetes/kubeadm/issues/1062 // Context: https://github.com/kubernetes/kubeadm/issues/1062
func enableIPForwarding(cr CommandRunner) error { func enableIPForwarding(cr CommandRunner) error {
c := exec.Command("sudo", "modprobe", "br_netfilter") c := exec.Command("sudo", "sysctl", "net.netfilter.nf_conntrack_count")
if _, err := cr.RunCmd(c); err != nil { if rr, err := cr.RunCmd(c); err != nil {
return errors.Wrap(err, "br_netfilter") glog.Infof("couldn't verify netfilter by %q which might be okay. error: %v", rr.Command(), err)
c = exec.Command("sudo", "modprobe", "br_netfilter")
if _, err := cr.RunCmd(c); err != nil {
return errors.Wrapf(err, "br_netfilter")
}
} }
c = exec.Command("sudo", "sh", "-c", "echo 1 > /proc/sys/net/ipv4/ip_forward") c = exec.Command("sudo", "sh", "-c", "echo 1 > /proc/sys/net/ipv4/ip_forward")
if _, err := cr.RunCmd(c); err != nil { if _, err := cr.RunCmd(c); err != nil {
return errors.Wrapf(err, "ip_forward") return errors.Wrapf(err, "ip_forward")