Skip to content

Commit

Permalink
修复csi panic bug (PaddlePaddle#1345)
Browse files Browse the repository at this point in the history
* fsCache删除不检查cluster

* 修复csi控制器 nil map问题

* 修复csi map 并发panic问题
  • Loading branch information
luoyuedong authored May 11, 2024
1 parent 1cd7675 commit 17e33ba
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/fs/csiplugin/controller/mount_point_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type MountPointController struct {
pvSynced cache.InformerSynced

queue workqueue.RateLimitingInterface
pvMapLock sync.Mutex
pvParamsMap map[string]pvParams
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
}
}

Expand Down

0 comments on commit 17e33ba

Please sign in to comment.