Commit 3ad4c65 1 parent e45ad21 commit 3ad4c65 Copy full SHA for 3ad4c65
File tree 3 files changed +14
-8
lines changed
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) {
116
116
debugLog ("[AppInsights] Error initializing kvs store: %v" , err )
117
117
return
118
118
}
119
-
120
- err = kvs .Lock (store .DefaultLockTimeout )
121
- if err != nil {
119
+ // Acquire store lock.
120
+ if err = kvs .Lock (store .DefaultLockTimeout ); err != nil {
122
121
log .Errorf ("getMetadata: Not able to acquire lock:%v" , err )
123
122
return
124
123
}
Original file line number Diff line number Diff line change 8
8
"fmt"
9
9
"os"
10
10
"runtime"
11
+ "time"
11
12
12
13
"github.com/Azure/azure-container-networking/common"
13
14
"github.com/Azure/azure-container-networking/log"
@@ -174,8 +175,12 @@ func (plugin *Plugin) InitializeKeyValueStore(config *common.PluginConfig) error
174
175
}
175
176
}
176
177
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 {
179
184
log .Printf ("[cni] Failed to lock store: %v." , err )
180
185
return errors .Wrap (err , "error Acquiring store lock" )
181
186
}
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ const (
23
23
LockExtension = ".lock"
24
24
25
25
// DefaultLockTimeout - lock timeout in milliseconds
26
- DefaultLockTimeout = 10000 * time .Millisecond
26
+ DefaultLockTimeout = 10000 * time .Millisecond
27
+ DefaultLockTimeoutWindows = 60000 * time .Millisecond
27
28
)
28
29
29
30
// jsonFileStore is an implementation of KeyValueStore using a local JSON file.
@@ -35,8 +36,9 @@ type jsonFileStore struct {
35
36
sync.Mutex
36
37
}
37
38
38
- //nolint:revive // ignoring name change
39
39
// NewJsonFileStore creates a new jsonFileStore object, accessed as a KeyValueStore.
40
+ //
41
+ //nolint:revive // ignoring name change
40
42
func NewJsonFileStore (fileName string , lockclient processlock.Interface ) (KeyValueStore , error ) {
41
43
if fileName == "" {
42
44
return & jsonFileStore {}, errors .New ("need to pass in a json file path" )
@@ -195,7 +197,7 @@ func (kvs *jsonFileStore) Lock(timeout time.Duration) error {
195
197
return errors .Wrap (err , "processLock acquire error" )
196
198
}
197
199
198
- log .Printf ("Acquired process lock" )
200
+ log .Printf ("Acquired process lock with timeout value of %v " , timeout )
199
201
return nil
200
202
}
201
203
You can’t perform that action at this time.
0 commit comments