File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
pkg/volume/csi/nodeinfomanager Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import (
25
25
"fmt"
26
26
"math"
27
27
"strings"
28
+ "sync"
28
29
29
30
"time"
30
31
@@ -66,6 +67,8 @@ type nodeInfoManager struct {
66
67
nodeName types.NodeName
67
68
volumeHost volume.VolumeHost
68
69
migratedPlugins map [string ](func () bool )
70
+ // lock protects changes to node.
71
+ lock sync.Mutex
69
72
}
70
73
71
74
// If no updates is needed, the function must return the same Node object as the input.
@@ -175,6 +178,9 @@ func (nim *nodeInfoManager) updateNode(updateFuncs ...nodeUpdateFunc) error {
175
178
// the effects of previous updateFuncs to avoid potential conflicts. For example, if multiple
176
179
// functions update the same field, updates in the last function are persisted.
177
180
func (nim * nodeInfoManager ) tryUpdateNode (updateFuncs ... nodeUpdateFunc ) error {
181
+ nim .lock .Lock ()
182
+ defer nim .lock .Unlock ()
183
+
178
184
// Retrieve the latest version of Node before attempting update, so that
179
185
// existing changes are not overwritten.
180
186
You can’t perform that action at this time.
0 commit comments