File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -116,9 +116,8 @@ func getMetadata(th *telemetryHandle) {
116116 debugLog ("[AppInsights] Error initializing kvs store: %v" , err )
117117 return
118118 }
119-
120- err = kvs .Lock (store .DefaultLockTimeout )
121- if err != nil {
119+ // Acquire store lock.
120+ if err = kvs .Lock (store .DefaultLockTimeout ); err != nil {
122121 log .Errorf ("getMetadata: Not able to acquire lock:%v" , err )
123122 return
124123 }
Original file line number Diff line number Diff line change 88 "fmt"
99 "os"
1010 "runtime"
11+ "time"
1112
1213 "github.com/Azure/azure-container-networking/common"
1314 "github.com/Azure/azure-container-networking/log"
@@ -174,8 +175,12 @@ func (plugin *Plugin) InitializeKeyValueStore(config *common.PluginConfig) error
174175 }
175176 }
176177
177- // Acquire store lock.
178- if err := plugin .Store .Lock (store .DefaultLockTimeout ); err != nil {
178+ // Acquire store lock. For windows 1m timeout is used while for Linux 10s timeout is assigned.
179+ var lockTimeoutValue time.Duration = store .DefaultLockTimeout
180+ if runtime .GOOS == "windows" {
181+ lockTimeoutValue = store .DefaultLockTimeoutWindows
182+ }
183+ if err := plugin .Store .Lock (lockTimeoutValue ); err != nil {
179184 log .Printf ("[cni] Failed to lock store: %v." , err )
180185 return errors .Wrap (err , "error Acquiring store lock" )
181186 }
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ const (
2323 LockExtension = ".lock"
2424
2525 // DefaultLockTimeout - lock timeout in milliseconds
26- DefaultLockTimeout = 10000 * time .Millisecond
26+ DefaultLockTimeout = 10000 * time .Millisecond
27+ DefaultLockTimeoutWindows = 60000 * time .Millisecond
2728)
2829
2930// jsonFileStore is an implementation of KeyValueStore using a local JSON file.
@@ -35,8 +36,9 @@ type jsonFileStore struct {
3536 sync.Mutex
3637}
3738
38- //nolint:revive // ignoring name change
3939// NewJsonFileStore creates a new jsonFileStore object, accessed as a KeyValueStore.
40+ //
41+ //nolint:revive // ignoring name change
4042func NewJsonFileStore (fileName string , lockclient processlock.Interface ) (KeyValueStore , error ) {
4143 if fileName == "" {
4244 return & jsonFileStore {}, errors .New ("need to pass in a json file path" )
@@ -195,7 +197,7 @@ func (kvs *jsonFileStore) Lock(timeout time.Duration) error {
195197 return errors .Wrap (err , "processLock acquire error" )
196198 }
197199
198- log .Printf ("Acquired process lock" )
200+ log .Printf ("Acquired process lock with timeout value of %v " , timeout )
199201 return nil
200202}
201203
You can’t perform that action at this time.
0 commit comments