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 {
|
||||
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 {
|
||||
devTree, err := dp.scan()
|
||||
@ -240,16 +242,13 @@ func (dp *devicePlugin) Scan(notifier dpapi.Notifier) error {
|
||||
klog.Warning("Failed to scan: ", err)
|
||||
}
|
||||
|
||||
found := 0
|
||||
for _, resource := range devTree {
|
||||
found += len(resource)
|
||||
}
|
||||
for name, prev := range previousCount {
|
||||
count := devTree.DeviceTypeCount(name)
|
||||
if count != prev {
|
||||
klog.V(1).Infof("GPU scan update: %d->%d '%s' resources found", prev, count, name)
|
||||
|
||||
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
|
||||
previousCount[name] = count
|
||||
}
|
||||
}
|
||||
|
||||
notifier.Notify(devTree)
|
||||
|
@ -100,6 +100,11 @@ func (tree DeviceTree) AddDevice(devType, id string, info DeviceInfo) {
|
||||
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
|
||||
// detected changes to a channel given by the creator of a Notifier object.
|
||||
type Notifier interface {
|
||||
|
Loading…
Reference in New Issue
Block a user