Skip to content

Commit 313878e

Browse files
added default wait timeot to 60 seconds to get iptable lock (#343)
1 parent 9cfec88 commit 313878e

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

npm/iptm/iptm.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ https://github.com/kubernetes/kubernetes/blob/master/pkg/util/iptables
77
package iptm
88

99
import (
10-
"fmt"
1110
"os"
1211
"os/exec"
13-
"strings"
1412
"syscall"
1513
"time"
1614

@@ -21,6 +19,10 @@ import (
2119
"k8s.io/apimachinery/pkg/util/wait"
2220
)
2321

22+
const (
23+
defaultlockWaitTimeInSeconds = "60"
24+
)
25+
2426
// IptEntry represents an iptables rule.
2527
type IptEntry struct {
2628
Command string
@@ -337,10 +339,11 @@ func (iptMgr *IptablesManager) Run(entry *IptEntry) (int, error) {
337339
entry.Command = util.Iptables
338340
}
339341

340-
waitFlag := fmt.Sprintf("%s %s", util.IptablesWaitFlag, entry.LockWaitTimeInSeconds)
341-
waitFlag = strings.TrimSpace(waitFlag)
342-
cmdArgs := append([]string{waitFlag, iptMgr.OperationFlag, entry.Chain}, entry.Specs...)
342+
if entry.LockWaitTimeInSeconds == "" {
343+
entry.LockWaitTimeInSeconds = defaultlockWaitTimeInSeconds
344+
}
343345

346+
cmdArgs := append([]string{util.IptablesWaitFlag, entry.LockWaitTimeInSeconds, iptMgr.OperationFlag, entry.Chain}, entry.Specs...)
344347
cmdOut, err := exec.Command(entry.Command, cmdArgs...).Output()
345348
log.Printf("%s\n", string(cmdOut))
346349

0 commit comments

Comments
 (0)