@@ -27,16 +27,19 @@ import (
2727
2828 "github.com/urfave/cli/v2"
2929
30+ "k8s.io/apimachinery/pkg/util/version"
3031 "k8s.io/dynamic-resource-allocation/kubeletplugin"
3132 "k8s.io/klog/v2"
3233
3334 "github.com/NVIDIA/k8s-dra-driver-gpu/internal/info"
35+ "github.com/NVIDIA/k8s-dra-driver-gpu/pkg/featuregates"
3436 "github.com/NVIDIA/k8s-dra-driver-gpu/pkg/flags"
3537)
3638
3739const (
38- DriverName = "compute-domain.nvidia.com"
39- DriverPluginCheckpointFileBasename = "checkpoint.json"
40+ DriverName = "compute-domain.nvidia.com"
41+ DriverPluginCheckpointFileBasename = "checkpoint.json"
42+ IMEXDaemonsWithDNSNamesMinDriverVersion = "570.158.01"
4043)
4144
4245type Flags struct {
@@ -186,6 +189,13 @@ func newApp() *cli.App {
186189
187190// RunPlugin initializes and runs the compute domain kubelet plugin.
188191func RunPlugin (ctx context.Context , config * Config ) error {
192+ // Check driver version if IMEXDaemonsWithDNSNames feature gate is enabled
193+ if featuregates .Enabled (featuregates .IMEXDaemonsWithDNSNames ) {
194+ if err := validateDriverVersionForIMEXDaemonsWithDNSNames (config .flags ); err != nil {
195+ return fmt .Errorf ("driver version validation failed: %w" , err )
196+ }
197+ }
198+
189199 // Create the plugin directory
190200 err := os .MkdirAll (config .DriverPluginPath (), 0750 )
191201 if err != nil {
@@ -263,3 +273,35 @@ func (c Config) setNvidiaCDIHookPath() error {
263273
264274 return nil
265275}
276+
277+ // validateDriverVersionForIMEXDaemonsWithDNSNames validates that the driver version
278+ // meets the minimum requirement for the IMEXDaemonsWithDNSNames feature gate.
279+ func validateDriverVersionForIMEXDaemonsWithDNSNames (flags * Flags ) error {
280+ klog .Infof ("Starting driver version validation for IMEXDaemonsWithDNSNames feature..." )
281+ klog .Infof ("Minimum required version: %s" , IMEXDaemonsWithDNSNamesMinDriverVersion )
282+
283+ containerDriverRoot := root (flags .containerDriverRoot )
284+ nvdevlib , err := newDeviceLib (containerDriverRoot )
285+ if err != nil {
286+ return fmt .Errorf ("failed to create device library: %w" , err )
287+ }
288+
289+ driverVer , err := nvdevlib .getDriverVersion ()
290+ if err != nil {
291+ return fmt .Errorf ("error getting driver version: %w" , err )
292+ }
293+
294+ minVersion , err := version .ParseGeneric (IMEXDaemonsWithDNSNamesMinDriverVersion )
295+ if err != nil {
296+ return fmt .Errorf ("error parsing minimum version: %w" , err )
297+ }
298+
299+ if driverVer .LessThan (minVersion ) {
300+ klog .Errorf ("IMEXDaemonsWithDNSNames feature requires driver version >= %s, but found %s" , minVersion .String (), driverVer .String ())
301+ klog .Errorf ("If installed via helm, set featureGates.IMEXDaemonsWithDNSNames=false to run without this feature." )
302+ return fmt .Errorf ("minimum version not satisfied" )
303+ }
304+
305+ klog .Infof ("Driver version validation passed: %s >= %s" , driverVer .String (), minVersion .String ())
306+ return nil
307+ }
0 commit comments