Skip to content

Commit 5686eba

Browse files
committed
Make ComptueDomains with DNS names the default
Signed-off-by: Kevin Klues <[email protected]>
1 parent 491c9ab commit 5686eba

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed

cmd/compute-domain-kubelet-plugin/device_state.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ import (
2525
resourceapi "k8s.io/api/resource/v1"
2626
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2727
"k8s.io/apimachinery/pkg/runtime"
28+
"k8s.io/apimachinery/pkg/util/version"
2829
"k8s.io/dynamic-resource-allocation/kubeletplugin"
2930
"k8s.io/klog/v2"
3031
"k8s.io/kubernetes/pkg/kubelet/checkpointmanager"
3132
cdiapi "tags.cncf.io/container-device-interface/pkg/cdi"
3233

3334
configapi "github.com/NVIDIA/k8s-dra-driver-gpu/api/nvidia.com/resource/v1beta1"
35+
"github.com/NVIDIA/k8s-dra-driver-gpu/pkg/featuregates"
3436
)
3537

3638
type OpaqueDeviceConfig struct {
@@ -62,6 +64,13 @@ func NewDeviceState(ctx context.Context, config *Config) (*DeviceState, error) {
6264
return nil, fmt.Errorf("failed to create device library: %w", err)
6365
}
6466

67+
// Check driver version if IMEXDaemonsWithDNSNames feature gate is enabled
68+
if featuregates.Enabled(featuregates.IMEXDaemonsWithDNSNames) {
69+
if err := validateDriverVersionForIMEXDaemonsWithDNSNames(config.flags, nvdevlib); err != nil {
70+
return nil, fmt.Errorf("driver version validation failed: %w", err)
71+
}
72+
}
73+
6574
allocatable, err := nvdevlib.enumerateAllPossibleDevices(config)
6675
if err != nil {
6776
return nil, fmt.Errorf("error enumerating all possible devices: %w", err)
@@ -561,6 +570,32 @@ func (s *DeviceState) getConfigResultsMap(rcs *resourceapi.ResourceClaimStatus,
561570
return configResultsMap, nil
562571
}
563572

573+
// validateDriverVersionForIMEXDaemonsWithDNSNames validates that the driver version
574+
// meets the minimum requirement for the IMEXDaemonsWithDNSNames feature gate.
575+
func validateDriverVersionForIMEXDaemonsWithDNSNames(flags *Flags, nvdevlib *deviceLib) error {
576+
klog.Infof("Starting driver version validation for IMEXDaemonsWithDNSNames feature...")
577+
klog.Infof("Minimum required version: %s", IMEXDaemonsWithDNSNamesMinDriverVersion)
578+
579+
driverVer, err := nvdevlib.getDriverVersion()
580+
if err != nil {
581+
return fmt.Errorf("error getting driver version: %w", err)
582+
}
583+
584+
minVersion, err := version.ParseGeneric(IMEXDaemonsWithDNSNamesMinDriverVersion)
585+
if err != nil {
586+
return fmt.Errorf("error parsing minimum version: %w", err)
587+
}
588+
589+
if driverVer.LessThan(minVersion) {
590+
klog.Errorf("IMEXDaemonsWithDNSNames feature requires driver version >= %s, but found %s", minVersion.String(), driverVer.String())
591+
klog.Errorf("If installed via helm, set featureGates.IMEXDaemonsWithDNSNames=false to disable feature")
592+
return fmt.Errorf("minimum version not satisfied for IMEXDaemonsWithDNSNames feature")
593+
}
594+
595+
klog.Infof("Driver version validation passed: %s >= %s", driverVer.String(), minVersion.String())
596+
return nil
597+
}
598+
564599
// GetOpaqueDeviceConfigs returns an ordered list of the configs contained in possibleConfigs for this driver.
565600
//
566601
// Configs can either come from the resource claim itself or from the device

cmd/compute-domain-kubelet-plugin/main.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ import (
3535
)
3636

3737
const (
38-
DriverName = "compute-domain.nvidia.com"
39-
DriverPluginCheckpointFileBasename = "checkpoint.json"
38+
DriverName = "compute-domain.nvidia.com"
39+
DriverPluginCheckpointFileBasename = "checkpoint.json"
40+
IMEXDaemonsWithDNSNamesMinDriverVersion = "570.158.01"
4041
)
4142

4243
type Flags struct {

cmd/compute-domain-kubelet-plugin/nvlib.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"strconv"
2727
"strings"
2828

29+
"k8s.io/apimachinery/pkg/util/version"
2930
"k8s.io/klog/v2"
3031
"k8s.io/mount-utils"
3132

@@ -125,6 +126,26 @@ func (l deviceLib) alwaysShutdown() {
125126
}
126127
}
127128

129+
func (l deviceLib) getDriverVersion() (*version.Version, error) {
130+
if err := l.init(); err != nil {
131+
return nil, fmt.Errorf("error initializing NVML: %w", err)
132+
}
133+
defer l.alwaysShutdown()
134+
135+
driverVersion, ret := l.nvmllib.SystemGetDriverVersion()
136+
if ret != nvml.SUCCESS {
137+
return nil, fmt.Errorf("error getting driver version: %v", ret)
138+
}
139+
140+
// Parse the version using Kubernetes version utilities
141+
v, err := version.ParseGeneric(driverVersion)
142+
if err != nil {
143+
return nil, fmt.Errorf("invalid driver version format '%s': %w", driverVersion, err)
144+
}
145+
146+
return v, nil
147+
}
148+
128149
func (l deviceLib) enumerateAllPossibleDevices(config *Config) (AllocatableDevices, error) {
129150
alldevices := make(AllocatableDevices)
130151

pkg/featuregates/featuregates.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ var defaultFeatureGates = map[featuregate.Feature]featuregate.VersionedSpecs{
6161
},
6262
IMEXDaemonsWithDNSNames: {
6363
{
64-
Default: false,
65-
PreRelease: featuregate.Alpha,
64+
Default: true,
65+
PreRelease: featuregate.Beta,
6666
Version: version.MajorMinor(25, 8),
6767
},
6868
},

0 commit comments

Comments
 (0)