mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-17 20:00:23 +00:00
rbd: improve healer to run multiple NodeStageVolume req concurrently
This will bring down the healer run time by a great factor. Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
This commit is contained in:
parent
b6a88dd728
commit
78f740d903
@ -18,6 +18,7 @@ package rbd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/ceph/ceph-csi/internal/util"
|
||||
|
||||
@ -127,6 +128,8 @@ func runVolumeHealer(ns *NodeServer, conf *util.Config) error {
|
||||
return err
|
||||
}
|
||||
|
||||
var wg sync.WaitGroup
|
||||
channel := make(chan error)
|
||||
for i := range val.Items {
|
||||
// skip if the volumeattachments doesn't belong to current node or driver
|
||||
if val.Items[i].Spec.NodeName != conf.NodeID || val.Items[i].Spec.Attacher != conf.DriverName {
|
||||
@ -165,10 +168,22 @@ func runVolumeHealer(ns *NodeServer, conf *util.Config) error {
|
||||
continue
|
||||
}
|
||||
|
||||
err = callNodeStageVolume(ns, c, pv, conf.StagingPath)
|
||||
if err != nil {
|
||||
util.ErrorLogMsg("callNodeStageVolume failed for VolID: %s, err: %v",
|
||||
pv.Spec.PersistentVolumeSource.CSI.VolumeHandle, err)
|
||||
wg.Add(1)
|
||||
// run multiple NodeStageVolume calls concurrently
|
||||
go func(wg *sync.WaitGroup, ns *NodeServer, c *k8s.Clientset, pv *v1.PersistentVolume, stagingPath string) {
|
||||
defer wg.Done()
|
||||
channel <- callNodeStageVolume(ns, c, pv, stagingPath)
|
||||
}(&wg, ns, c, pv, conf.StagingPath)
|
||||
}
|
||||
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(channel)
|
||||
}()
|
||||
|
||||
for s := range channel {
|
||||
if s != nil {
|
||||
util.ErrorLogMsg("callNodeStageVolume failed, err: %v", s)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user