mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
Add lock for csiNode update
Signed-off-by: novahe <heqianfly@gmail.com>
This commit is contained in:
parent
2b3da7dfc8
commit
a70b6b9105
@ -379,6 +379,9 @@ func (nim *nodeInfoManager) tryUpdateCSINode(
|
||||
maxAttachLimit int64,
|
||||
topology map[string]string) error {
|
||||
|
||||
nim.lock.Lock()
|
||||
defer nim.lock.Unlock()
|
||||
|
||||
nodeInfo, err := csiKubeClient.StorageV1().CSINodes().Get(context.TODO(), string(nim.nodeName), metav1.GetOptions{})
|
||||
if nodeInfo == nil || errors.IsNotFound(err) {
|
||||
nodeInfo, err = nim.CreateCSINode()
|
||||
@ -412,6 +415,9 @@ func (nim *nodeInfoManager) InitializeCSINodeWithAnnotation() error {
|
||||
}
|
||||
|
||||
func (nim *nodeInfoManager) tryInitializeCSINodeWithAnnotation(csiKubeClient clientset.Interface) error {
|
||||
nim.lock.Lock()
|
||||
defer nim.lock.Unlock()
|
||||
|
||||
nodeInfo, err := csiKubeClient.StorageV1().CSINodes().Get(context.TODO(), string(nim.nodeName), metav1.GetOptions{})
|
||||
if nodeInfo == nil || errors.IsNotFound(err) {
|
||||
// CreateCSINode will set the annotation
|
||||
@ -602,6 +608,9 @@ func (nim *nodeInfoManager) tryUninstallDriverFromCSINode(
|
||||
csiKubeClient clientset.Interface,
|
||||
csiDriverName string) error {
|
||||
|
||||
nim.lock.Lock()
|
||||
defer nim.lock.Unlock()
|
||||
|
||||
nodeInfoClient := csiKubeClient.StorageV1().CSINodes()
|
||||
nodeInfo, err := nodeInfoClient.Get(context.TODO(), string(nim.nodeName), metav1.GetOptions{})
|
||||
if err != nil && errors.IsNotFound(err) {
|
||||
|
Loading…
Reference in New Issue
Block a user