| 1920 | } |
| 1921 | |
| 1922 | func (v *VGPUDevices) runValidation() error { |
| 1923 | nvmdev := nvmdev.New() |
| 1924 | vGPUDevices, err := nvmdev.GetAllDevices() |
| 1925 | if err != nil { |
| 1926 | return fmt.Errorf("error checking for vGPU devices on the host: %w", err) |
| 1927 | } |
| 1928 | |
| 1929 | if !withWaitFlag { |
| 1930 | numDevices := len(vGPUDevices) |
| 1931 | if numDevices == 0 { |
| 1932 | return fmt.Errorf("no vGPU devices found") |
| 1933 | } |
| 1934 | |
| 1935 | log.Infof("Found %d vGPU devices", numDevices) |
| 1936 | return nil |
| 1937 | } |
| 1938 | |
| 1939 | for { |
| 1940 | numDevices := len(vGPUDevices) |
| 1941 | if numDevices > 0 { |
| 1942 | log.Infof("Found %d vGPU devices", numDevices) |
| 1943 | return nil |
| 1944 | } |
| 1945 | log.Infof("No vGPU devices found, retrying after %d seconds", sleepIntervalSecondsFlag) |
| 1946 | time.Sleep(time.Duration(sleepIntervalSecondsFlag) * time.Second) |
| 1947 | |
| 1948 | vGPUDevices, err = nvmdev.GetAllDevices() |
| 1949 | if err != nil { |
| 1950 | return fmt.Errorf("error checking for vGPU devices on the host: %w", err) |
| 1951 | } |
| 1952 | } |
| 1953 | } |