Skip to content

Commit

Permalink
[controller] Fix max volumes per node and R/W map (#19)
Browse files Browse the repository at this point in the history
* [controller] Fix max volumes per node and concurrent map access in extender-scheduler
Signed-off-by: Viktor Kramarenko <[email protected]>
  • Loading branch information
ViktorKram authored Mar 26, 2024
1 parent 36741ef commit 1e1ad1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions images/sds-local-volume-csi/driver/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ func (d *Driver) NodeGetInfo(ctx context.Context, request *csi.NodeGetInfoReques
d.log.Info("hostID = ", d.hostID)

return &csi.NodeGetInfoResponse{
NodeId: d.hostID,
MaxVolumesPerNode: 10,
NodeId: d.hostID,
//MaxVolumesPerNode: 10,
AccessibleTopology: &csi.Topology{
Segments: map[string]string{
internal.TopologyKey: d.hostID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ func filterNodes(
return nil, err
}
log.Trace(fmt.Sprintf("[filterNodes] LVGs Thick FreeSpace: %+v", lvgsThickFree))

scLVGs, err := getSortedLVGsFromStorageClasses(scs)
if err != nil {
return nil, err
Expand All @@ -208,6 +207,7 @@ func filterNodes(
FailedNodes: FailedNodesMap{},
}

mutex := &sync.RWMutex{}
wg := &sync.WaitGroup{}
wg.Add(len(nodes.Items))
errs := make(chan error, len(nodes.Items)*len(pvcs))
Expand Down Expand Up @@ -242,15 +242,19 @@ func filterNodes(
switch pvcReq.DeviceType {
case thick:
lvg := lvgs[matchedLVG.Name]
mutex.RLock()
freeSpace := lvgsThickFree[lvg.Name]
mutex.RUnlock()

log.Trace(fmt.Sprintf("[filterNodes] Thick free space: %d, PVC requested space: %d", freeSpace, pvcReq.RequestedSize))
if freeSpace < pvcReq.RequestedSize {
hasEnoughSpace = false
break
}

mutex.Lock()
lvgsThickFree[lvg.Name] -= pvcReq.RequestedSize
mutex.Unlock()
case thin:
lvg := lvgs[matchedLVG.Name]
targetThinPool := findMatchedThinPool(lvg.Status.ThinPools, matchedLVG.Thin.PoolName)
Expand Down

0 comments on commit 1e1ad1e

Please sign in to comment.