mirror of
https://github.com/intel/intel-device-plugins-for-kubernetes.git
synced 2025-06-03 03:59:37 +00:00
Log GPU device share count & type count changes separately
And instead of accessing DeviceTree internals, add suitable method for it. Signed-off-by: Eero Tamminen <eero.t.tamminen@intel.com>
This commit is contained in:
parent
d826548d29
commit
fb18923298
@ -232,7 +232,9 @@ func (dp *devicePlugin) GetPreferredAllocation(rqt *pluginapi.PreferredAllocatio
|
|||||||
func (dp *devicePlugin) Scan(notifier dpapi.Notifier) error {
|
func (dp *devicePlugin) Scan(notifier dpapi.Notifier) error {
|
||||||
defer dp.scanTicker.Stop()
|
defer dp.scanTicker.Stop()
|
||||||
|
|
||||||
var previouslyFound = -1
|
klog.V(1).Infof("GPU '%s' resource share count = %d", deviceType, dp.options.sharedDevNum)
|
||||||
|
|
||||||
|
previousCount := map[string]int{deviceType: 0, monitorType: 0}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
devTree, err := dp.scan()
|
devTree, err := dp.scan()
|
||||||
@ -240,16 +242,13 @@ func (dp *devicePlugin) Scan(notifier dpapi.Notifier) error {
|
|||||||
klog.Warning("Failed to scan: ", err)
|
klog.Warning("Failed to scan: ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
found := 0
|
for name, prev := range previousCount {
|
||||||
for _, resource := range devTree {
|
count := devTree.DeviceTypeCount(name)
|
||||||
found += len(resource)
|
if count != prev {
|
||||||
|
klog.V(1).Infof("GPU scan update: %d->%d '%s' resources found", prev, count, name)
|
||||||
|
|
||||||
|
previousCount[name] = count
|
||||||
}
|
}
|
||||||
|
|
||||||
if found != previouslyFound {
|
|
||||||
klog.V(1).Infof("GPU scan update: %d device resources (with %dx sharing) of %d types found",
|
|
||||||
found, dp.options.sharedDevNum, len(devTree))
|
|
||||||
|
|
||||||
previouslyFound = found
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notifier.Notify(devTree)
|
notifier.Notify(devTree)
|
||||||
|
@ -100,6 +100,11 @@ func (tree DeviceTree) AddDevice(devType, id string, info DeviceInfo) {
|
|||||||
tree[devType][id] = info
|
tree[devType][id] = info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DeviceTypeCount returns number of device of given type.
|
||||||
|
func (tree DeviceTree) DeviceTypeCount(devType string) int {
|
||||||
|
return len(tree[devType])
|
||||||
|
}
|
||||||
|
|
||||||
// Notifier receives updates from Scanner, detects changes and sends the
|
// Notifier receives updates from Scanner, detects changes and sends the
|
||||||
// detected changes to a channel given by the creator of a Notifier object.
|
// detected changes to a channel given by the creator of a Notifier object.
|
||||||
type Notifier interface {
|
type Notifier interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user