From 17e33bafda2de1b1db2033dde746bf37595865fb Mon Sep 17 00:00:00 2001 From: luoyuedong Date: Sat, 11 May 2024 10:54:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcsi=20panic=20bug=20=20(#1345?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fsCache删除不检查cluster * 修复csi控制器 nil map问题 * 修复csi map 并发panic问题 --- pkg/fs/csiplugin/controller/mount_point_controller.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/fs/csiplugin/controller/mount_point_controller.go b/pkg/fs/csiplugin/controller/mount_point_controller.go index b740112e1..9b8203134 100644 --- a/pkg/fs/csiplugin/controller/mount_point_controller.go +++ b/pkg/fs/csiplugin/controller/mount_point_controller.go @@ -68,6 +68,7 @@ type MountPointController struct { pvSynced cache.InformerSynced queue workqueue.RateLimitingInterface + pvMapLock sync.Mutex pvParamsMap map[string]pvParams } @@ -202,7 +203,9 @@ func (m *MountPointController) UpdatePodMap() error { pvs, err := client.ListPersistentVolume(metav1.ListOptions{}) for _, pv := range pvs.Items { if pv.Spec.CSI != nil && pv.Spec.CSI.Driver == "paddleflowstorage" { + m.pvMapLock.Lock() m.pvParamsMap[pv.Name] = buildPfsPvParams(pv.Spec.CSI.VolumeAttributes) + m.pvMapLock.Unlock() } } return nil @@ -245,7 +248,9 @@ func (m *MountPointController) handleRunningPod(pod v1.Pod, updateMounts bool) { func (m *MountPointController) CheckAndRemountVolumeMount(volumeMount volumeMountInfo) error { // TODO(dongzezhao) get mountParameters from volumeMountInfo + m.pvMapLock.Lock() pvParams_, ok := m.pvParamsMap[volumeMount.VolumeName] + m.pvMapLock.Unlock() if !ok { log.Errorf("get pfs parameters [%s] not exist", volumeMount.VolumeName) return fmt.Errorf("get pfs parameters [%s] not exist", volumeMount.VolumeName) @@ -402,7 +407,9 @@ func (m *MountPointController) pvAddedUpdated(obj interface{}) { // update pv if pv.Spec.StorageClassName == "paddleflowstorage" { + m.pvMapLock.Lock() m.pvParamsMap[pv.Name] = buildPfsPvParams(pv.Spec.CSI.VolumeAttributes) + m.pvMapLock.Unlock() } }