From 85eab52ffa1ce4b2f9af09afc2c27184ec4f2381 Mon Sep 17 00:00:00 2001 From: Tamilmani Manoharan Date: Wed, 24 Apr 2019 16:16:51 -0700 Subject: [PATCH] added default wait timeot to 60 seconds to get iptable lock --- npm/iptm/iptm.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/npm/iptm/iptm.go b/npm/iptm/iptm.go index fbc87ef5c9..3acfe5dbb2 100644 --- a/npm/iptm/iptm.go +++ b/npm/iptm/iptm.go @@ -7,10 +7,8 @@ https://github.com/kubernetes/kubernetes/blob/master/pkg/util/iptables package iptm import ( - "fmt" "os" "os/exec" - "strings" "syscall" "time" @@ -21,6 +19,10 @@ import ( "k8s.io/apimachinery/pkg/util/wait" ) +const ( + defaultlockWaitTimeInSeconds = "60" +) + // IptEntry represents an iptables rule. type IptEntry struct { Command string @@ -337,10 +339,11 @@ func (iptMgr *IptablesManager) Run(entry *IptEntry) (int, error) { entry.Command = util.Iptables } - waitFlag := fmt.Sprintf("%s %s", util.IptablesWaitFlag, entry.LockWaitTimeInSeconds) - waitFlag = strings.TrimSpace(waitFlag) - cmdArgs := append([]string{waitFlag, iptMgr.OperationFlag, entry.Chain}, entry.Specs...) + if entry.LockWaitTimeInSeconds == "" { + entry.LockWaitTimeInSeconds = defaultlockWaitTimeInSeconds + } + cmdArgs := append([]string{util.IptablesWaitFlag, entry.LockWaitTimeInSeconds, iptMgr.OperationFlag, entry.Chain}, entry.Specs...) cmdOut, err := exec.Command(entry.Command, cmdArgs...).Output() log.Printf("%s\n", string(cmdOut))