Skip to content

Commit a386846

Browse files
author
John Howard
committed
Store fixes; Windows compile
Signed-off-by: John Howard <[email protected]> - First, the store timeout is woefully low. Bumped to 20 seconds from 2 seconds. This may fix #242 (comment) IMO, as only test code calls it non-blocked, why even have a block parameter to Lock()? IMO also, why a timeout at all? They're always fraught with error and machine timing. - Presence of a key should be checked using `raw, ok := hvs.data[key]`, not the current nil checked - ErrKeyNotFound should be returned if the store file does not exist. It shouldn't ignore that error. - Actually now reports if a timeout occurred correctly, along with non-block lock attempt when already locked. - Serial pattern abuse in not always closing the lock file. - Some golang correctness (errors should be lower case) - go build ./... actually passes on Windows now - various compile errors previously. - golang pattern conformance `if err:=<test>; err!=nil {....` - Simplified timeout duration (no need for time.Duration(...))
1 parent 009ebee commit a386846

File tree

16 files changed

+48
-43
lines changed

16 files changed

+48
-43
lines changed

cni/plugin.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ func (plugin *Plugin) InitializeKeyValueStore(config *common.PluginConfig) error
161161
var err error
162162
plugin.Store, err = store.NewJsonFileStore(platform.CNIRuntimePath + plugin.Name + ".json")
163163
if err != nil {
164-
log.Printf("[cni] Failed to create store, err:%v.", err)
164+
log.Printf("[cni] Failed to create store: %v.", err)
165165
return err
166166
}
167167
}
168168

169169
// Acquire store lock.
170170
if err := plugin.Store.Lock(true); err != nil {
171-
log.Printf("[cni] Timed out on locking store, err:%v.", err)
171+
log.Printf("[cni] Failed to lock store: %v.", err)
172172
return err
173173
}
174174

@@ -182,7 +182,7 @@ func (plugin *Plugin) UninitializeKeyValueStore() error {
182182
if plugin.Store != nil {
183183
err := plugin.Store.Unlock()
184184
if err != nil {
185-
log.Printf("[cni] Failed to unlock store, err:%v.", err)
185+
log.Printf("[cni] Failed to unlock store: %v.", err)
186186
return err
187187
}
188188
}

netlink/ip.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4+
// +build linux
5+
46
package netlink
57

68
import (

netlink/link.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4+
// +build linux
5+
46
package netlink
57

68
import (

netlink/netlink.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4+
// +build linux
5+
46
package netlink
57

68
import (

netlink/netlink_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4+
// +build linux
5+
46
package netlink
57

68
import (

netlink/netlink_windows.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Copyright 2017 Microsoft. All rights reserved.
2+
// MIT License
3+
4+
package netlink

netlink/protocol.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4+
// +build linux
5+
46
package netlink
57

68
import (

netlink/socket.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4+
// +build linux
5+
46
package netlink
57

68
import (

network/endpoint_linux.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4-
// +build linux
5-
64
package network
75

86
import (

network/endpoint_windows.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Copyright 2017 Microsoft. All rights reserved.
22
// MIT License
33

4-
// +build windows
5-
64
package network
75

86
import (

0 commit comments

Comments
 (0)