Skip to content

Commit a084f4d

Browse files
cxfcxfxchen
authored andcommitted
Prevent volume from schedualing to offline or readonly pool (#448)
* Prevent volume from schedualing to offline or readonly pool Signed-off-by: xchen <[email protected]> * code syntax match Signed-off-by: xchen <[email protected]> --------- Signed-off-by: xchen <[email protected]> Co-authored-by: xchen <[email protected]> Signed-off-by: Niladri Halder <[email protected]>
1 parent eb5ec54 commit a084f4d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

pkg/controllers/cstorvolumeconfig/volume_operations.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ func (c *CVCController) distributeCVRs(
391391
usablePoolList = getUsablePoolList(c.clientset, volume.Name, poolList)
392392
}
393393

394+
// sanitizePoolList to remove pool that has status.Phase as offline
395+
// or Status.ReadOnly as true from usablePoolList
396+
usablePoolList = sanitizePoolList(usablePoolList)
397+
394398
// randomizePoolList to get the pool list in random order
395399
usablePoolList = randomizePoolList(usablePoolList)
396400

@@ -597,6 +601,22 @@ func prioritizedPoolList(nodeName string, list *apis.CStorPoolInstanceList) *api
597601
return list
598602
}
599603

604+
// sanitizePoolList returns santized pool list
605+
// 1. It removes the pool from the list if its phase is offline.
606+
// 2. It removes the pool from the list if its readonly.
607+
func sanitizePoolList(list *apis.CStorPoolInstanceList) *apis.CStorPoolInstanceList {
608+
res := &apis.CStorPoolInstanceList{}
609+
610+
for _, pool := range list.Items {
611+
if pool.Status.Phase == apis.CStorPoolStatusOffline || pool.Status.ReadOnly {
612+
continue
613+
}
614+
615+
res.Items = append(res.Items, pool)
616+
}
617+
return res
618+
}
619+
600620
// randomizePoolList returns randomized pool list
601621
func randomizePoolList(list *apis.CStorPoolInstanceList) *apis.CStorPoolInstanceList {
602622
res := &apis.CStorPoolInstanceList{}

0 commit comments

Comments
 (0)