diff --git a/cmd/main.go b/cmd/main.go index 4154ae71..35226f56 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -31,10 +31,12 @@ package main import ( "github.com/nvidia/sandbox-device-plugin/pkg/device_plugin" "os" + "strconv" ) func main() { var ok bool + var enableGFDFlag string device_plugin.PGPUAlias, ok = os.LookupEnv("P_GPU_ALIAS") if !ok { device_plugin.PGPUAlias = "pgpu" @@ -43,5 +45,10 @@ func main() { if !ok { device_plugin.NVSwitchAlias = "nvswitch" } + enableGFDFlag, ok = os.LookupEnv("ENABLE_GFD") + // default is false + if ok { + device_plugin.EnableGFD, _ = strconv.ParseBool(enableGFDFlag) + } device_plugin.InitiateDevicePlugin() } diff --git a/pkg/device_plugin/constants.go b/pkg/device_plugin/constants.go index 5c6694fd..970522c5 100644 --- a/pkg/device_plugin/constants.go +++ b/pkg/device_plugin/constants.go @@ -46,6 +46,8 @@ var ( rootPath = "/" // cdiRoot can be set for testing to redirect CDI spec output cdiRoot = "/var/run/cdi" + // Flag to allow running GFD pod + EnableGFD = false ) func setCdiRoot(path string) { diff --git a/pkg/device_plugin/device_plugin.go b/pkg/device_plugin/device_plugin.go index 99cdbbb9..98a84785 100644 --- a/pkg/device_plugin/device_plugin.go +++ b/pkg/device_plugin/device_plugin.go @@ -133,7 +133,9 @@ func createDevicePlugins() { } // run GFD job - go runGFD() + if EnableGFD { + go runGFD() + } <-stop