Skip to content

Commit

Permalink
adding scheduler as a configurable option
Browse files Browse the repository at this point in the history
Signed-off-by: Pawan <pawan@mayadata.io>
  • Loading branch information
pawanpraka1 committed Nov 4, 2019
1 parent e615c26 commit 1935ab7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/driver/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ func (cs *controller) CreateVolume(
kl := req.GetParameters()["keylocation"]
pool := req.GetParameters()["poolname"]
tp := req.GetParameters()["thinprovision"]
schld := req.GetParameters()["scheduler"]

selected := scheduler(req.AccessibilityRequirements, pool)
selected := scheduler(req.AccessibilityRequirements, schld, pool)

if len(selected) == 0 {
return nil, status.Error(codes.Internal, "scheduler failed")
Expand Down
18 changes: 15 additions & 3 deletions pkg/driver/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ import (
zvol "github.com/openebs/zfs-localpv/pkg/zfs"
)

// scheduling algorithm constants
const (
// pick the node where less volumes are provisioned for the given pool
// this will be the default scheduler when none provided
VolumeWeighted = "VolumeWeighted"
)

// volumeWeightedScheduler goes through all the pools on the nodes mentioned
// in the topology and picks the node which has less volume on
// the given zfs pool.
Expand Down Expand Up @@ -66,14 +73,19 @@ func volumeWeightedScheduler(topo *csi.TopologyRequirement, pool string) string

// scheduler schedules the PV as per topology constraints for
// the given zfs pool.
func scheduler(topo *csi.TopologyRequirement, pool string) string {
func scheduler(topo *csi.TopologyRequirement, schld string, pool string) string {

// if there is a single node, schedule it on that
if len(topo.Preferred) == 1 {
return topo.Preferred[0].Segments[zvol.ZFSTopologyKey]
}

selected := volumeWeightedScheduler(topo, pool)
switch schld {
case VolumeWeighted:
return volumeWeightedScheduler(topo, pool)
default:
return volumeWeightedScheduler(topo, pool)
}

return selected
return ""
}

0 comments on commit 1935ab7

Please sign in to comment.