From 8db8a6b7de5b041da977e31f8666c20c53b59b0b Mon Sep 17 00:00:00 2001 From: Lucas Manning Date: Mon, 26 Aug 2024 11:14:31 -0700 Subject: [PATCH] Return an error if there aren't any TPU devices when --tpuproxy is enabled. PiperOrigin-RevId: 667648344 --- runsc/cmd/chroot.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/runsc/cmd/chroot.go b/runsc/cmd/chroot.go index 8e4bbef536..9570d22c9a 100644 --- a/runsc/cmd/chroot.go +++ b/runsc/cmd/chroot.go @@ -202,16 +202,21 @@ func tpuProxyUpdateChroot(chroot string, spec *specs.Spec, conf *config.Config) // Bind mount device info directories for all TPU devices on the host. // For v4 TPU, the directory /sys/devices///accel/accel# is mounted; // For v5e TPU, the directory /sys/devices///vfio-dev/vfio# is mounted. + foundDevices := false for pathGlob, sysfsFormat := range pathGlobToSysfsFormat { paths, err := filepath.Glob(pathGlob) if err != nil { return fmt.Errorf("enumerating TPU device files: %w", err) } for _, devPath := range paths { + foundDevices = true if err := mountTPUDeviceInfoInChroot(chroot, devPath, sysfsFormat, pathGlobToPciDeviceFormat[pathGlob]); err != nil { return err } } } + if !foundDevices { + return fmt.Errorf("could not find any TPU devices on the host") + } return nil }