fix: delayed probing GPU on host init and add disable_gpu option

This commit is contained in:
Qiu Jian
2021-10-30 11:46:16 +08:00
parent df82bd1cb9
commit a970249cc1
3 changed files with 22 additions and 11 deletions
+10 -6
View File
@@ -311,11 +311,7 @@ func (h *SHostInfo) parseConfig() error {
h.MasterNic = nil
}
if man, err := isolated_device.NewManager(h); err != nil {
return fmt.Errorf("NewIsolatedManager: %v", err)
} else {
h.IsolatedDeviceMan = man
}
h.IsolatedDeviceMan = isolated_device.NewManager(h)
return nil
}
@@ -1473,7 +1469,15 @@ func (h *SHostInfo) uploadStorageInfo() {
go storageman.StartSyncStorageSizeTask(
time.Duration(options.HostOptions.SyncStorageInfoDurationSecond) * time.Second,
)
h.getIsolatedDevices()
var err error
if !options.HostOptions.DisableGPU {
err = h.IsolatedDeviceMan.ProbePCIDevices()
}
if err != nil {
h.onFail(errors.Wrap(err, "Probe PCI device failed"))
} else {
h.getIsolatedDevices()
}
}
func (h *SHostInfo) onSyncStorageInfoSucc(storage storageman.IStorage, storageInfo jsonutils.JSONObject) {
@@ -96,17 +96,22 @@ type IsolatedDeviceManager struct {
DetachedDevices []*CloudDeviceInfo
}
func NewManager(host IHost) (*IsolatedDeviceManager, error) {
func NewManager(host IHost) *IsolatedDeviceManager {
man := &IsolatedDeviceManager{
host: host,
Devices: make([]IDevice, 0),
DetachedDevices: make([]*CloudDeviceInfo, 0),
}
err := man.fillPCIDevices()
return man, err
// Do probe laster - Qiu Jian
// err := man.fillPCIDevices()
return man
}
func (man *IsolatedDeviceManager) fillPCIDevices() error {
func (man *IsolatedDeviceManager) ProbePCIDevices() error {
if len(man.Devices) > 0 {
// already probed, skip
return nil
}
// only support gpu by now
gpus, err := getPassthroughGPUS()
if err != nil {
+3 -1
View File
@@ -143,7 +143,9 @@ type SHostOptions struct {
DisableProbeKubelet bool `help:"Disable probe kubelet config" default:"false"`
KubeletRunDirectory string `help:"Kubelet config file path" default:"/var/lib/kubelet"`
DisableKVM bool `help:"force disable KVM" default:"false"`
DisableKVM bool `help:"force disable KVM" default:"false" json:"disable_kvm"`
DisableGPU bool `help:"force disable GPU" default:"false" json:"disable_gpu"`
}
var (