You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found two scheduling algorithms getCapacityWeightedMap and getCapacityWeightedMap in the project , according to actual needs, I plan to implement a scheduling algorithm getFreeCapacityWeightedMap, it can be scores to nodes by disk free capacity, something like this:
device-localpv/pkg/driver/schd_helper.go:
// key value struct for creating the node listtypekvstruct {
KeystringValueint64
}
funcgetFreeCapacityWeightedMap(deviceNamestring) (map[string]int64, error) {
nmap:=map[string]int64{}
nodeList, err:=nodebuilder.NewKubeclient().
WithNamespace(device.DeviceNamespace).
List(metav1.ListOptions{})
iferr!=nil {
returnnmap, err
}
// create the map of the free capacity// for the given deviceNamenFreeMap:=map[string]int64{}
for_, n:=rangenodeList.Items {
for_, dev:=rangen.Devices {
i, ok:=dev.Free.AsInt64()
if!ok {
klog.Infof("Disk: Free capacity convert int64 failure %s, %+v", dev.Free, err)
continue
}
devRegex, err:=regexp.Compile(dev.Name)
iferr!=nil {
klog.Infof("Disk: Regex compile failure %s, %+v", dev.Name, err)
continue
}
ifdevRegex.MatchString(deviceName) {
nFreeMap[n.Name] +=i
}
}
}
varnList []kvfork, v:=rangenFreeMap {
nList=append(nList, kv{k, v})
}
// sort the node map by free capacitysort.Slice(nList, func(i, jint) bool {
returnnList[i].Value>nList[j].Value
})
// score nodes by free capacityfori, v:=rangenList {
nmap[v.Key] =int64(i)
}
returnnmap, nil
}
It can query the disk free capacity on all nodes, and give higher scores to nodes with larger disk free capacity.
To do this, I will also modify the code that creates the DeviceNode CRD:
device-localpv/pkg/mgmt/devicenode/devicenode.go:
// syncNode is the function which tries to converge to a desired state for the// DeviceNodefunc (c*NodeController) syncNode(namespacestring, namestring) error {
...ifnode==nil { // if it doesn't exists, create device node objectifdevices==nil {
devices= []apis.Device{}
}
ifnode, err=nodebuilder.NewBuilder().
WithNamespace(namespace).WithName(name).
WithDevices(devices).
WithOwnerReferences(c.ownerRef).
Build(); err!=nil {
returnerr
}
klog.Infof("device node controller: creating new node object for %+v", node)
ifnode, err=nodebuilder.NewKubeclient().WithNamespace(namespace).Create(node); err!=nil {
returnfmt.Errorf("create device node %s/%s: %v", namespace, name, err)
}
klog.Infof("device node controller: created node object %s/%s", namespace, name)
returnnil
}
...
}
add this code:
ifdevices==nil {
devices= []apis.Device{}
}
To avoid DeviceNode creation failure when devices == nil, the purpose is to query nodes without free capacity in getFreeCapacityWeightedMap, in this way, when scoring according to the free capacity, nodes with no free capacity will get a very low score, avoiding PV scheduling in the past.
That's my plan, looking forward to making suggestions and requests.
The text was updated successfully, but these errors were encountered:
I found two scheduling algorithms
getCapacityWeightedMap
andgetCapacityWeightedMap
in the project , according to actual needs, I plan to implement a scheduling algorithmgetFreeCapacityWeightedMap
, it can be scores to nodes by disk free capacity, something like this:device-localpv/pkg/driver/schd_helper.go
:It can query the disk free capacity on all nodes, and give higher scores to nodes with larger disk free capacity.
To do this, I will also modify the code that creates the
DeviceNode
CRD:device-localpv/pkg/mgmt/devicenode/devicenode.go
:add this code:
To avoid
DeviceNode
creation failure whendevices == nil
, the purpose is to query nodes without free capacity ingetFreeCapacityWeightedMap
, in this way, when scoring according to the free capacity, nodes with no free capacity will get a very low score, avoiding PV scheduling in the past.That's my plan, looking forward to making suggestions and requests.
The text was updated successfully, but these errors were encountered: