diff --git a/cmd/nvidia-validator/main.go b/cmd/nvidia-validator/main.go index 3dd1f5224..4215b045d 100644 --- a/cmd/nvidia-validator/main.go +++ b/cmd/nvidia-validator/main.go @@ -30,7 +30,8 @@ import ( "github.com/NVIDIA/go-nvlib/pkg/nvmdev" "github.com/NVIDIA/go-nvlib/pkg/nvpci" - devchar "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks" + "github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices" + "github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules" log "github.com/sirupsen/logrus" cli "github.com/urfave/cli/v2" corev1 "k8s.io/api/core/v1" @@ -865,21 +866,27 @@ func createDevCharSymlinks(driverInfo driverInfo, disableDevCharSymlinkCreation driverRootCtrPath = "/host" } - // We now create the symlinks in /dev/char. - creator, err := devchar.NewSymlinkCreator( - devchar.WithDriverRoot(driverRootCtrPath), - devchar.WithDevRoot(driverInfo.devRoot), - devchar.WithDevCharPath(hostDevCharPath), - devchar.WithCreateAll(true), - devchar.WithCreateDeviceNodes(true), - devchar.WithLoadKernelModules(loadKernelModules), + if loadKernelModules { + modules := nvmodules.New( + nvmodules.WithRoot(driverRootCtrPath), + ) + if err := modules.LoadAll(); err != nil { + return fmt.Errorf("failed to load NVIDIA kernel modules: %v", err) + } + } + + devices, err := nvdevices.New( + nvdevices.WithDevRoot(driverInfo.devRoot), ) if err != nil { - return fmt.Errorf("error creating symlink creator: %w", err) + return err } - err = creator.CreateLinks() - if err != nil { + if err := devices.CreateNVIDIAControlDevices(); err != nil { + return fmt.Errorf("failed to create device nodes for NVIDIA control devices: %v", err) + } + // We now create the symlinks in /dev/char on the host. + if err := devices.CreateDevCharSymlinks(hostDevCharPath, false); err != nil { return fmt.Errorf("error creating symlinks: %w", err) } diff --git a/go.mod b/go.mod index 7eccedd5e..098efced2 100644 --- a/go.mod +++ b/go.mod @@ -97,7 +97,7 @@ require ( github.com/spf13/cobra v1.10.1 // indirect github.com/spf13/pflag v1.0.9 // indirect github.com/ulikunitz/xz v0.5.15 // indirect - github.com/urfave/cli/v3 v3.4.1 // indirect + github.com/urfave/cli/v3 v3.5.0 // indirect github.com/x448/float16 v0.8.4 // indirect github.com/xlab/treeprint v1.2.0 // indirect github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect @@ -129,3 +129,5 @@ require ( sigs.k8s.io/randfill v1.0.0 // indirect sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect ) + +replace github.com/NVIDIA/nvidia-container-toolkit => ../container-toolkit diff --git a/go.sum b/go.sum index 5649483e4..a24c8627f 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,6 @@ github.com/NVIDIA/k8s-kata-manager v0.2.3 h1:d5+gRFqU5el/fKMXhHUaPY7haj+dbHL4nDs github.com/NVIDIA/k8s-kata-manager v0.2.3/go.mod h1:xx5OUiMsHyKbyX0JjKHqAftvqS8vx00LFn/5EaMdtB4= github.com/NVIDIA/k8s-operator-libs v0.0.0-20250709180754-c80af13d73e3 h1:vGT+oyUY7kOGLd71Cz0NfRVEep23jdd4fi+PYsZEj88= github.com/NVIDIA/k8s-operator-libs v0.0.0-20250709180754-c80af13d73e3/go.mod h1:0GPZJRwr6nY1IVhGUyzG9YfKhNFQq8UlhYe4u7jVF0U= -github.com/NVIDIA/nvidia-container-toolkit v1.18.0 h1:bXoKq9C1WHU5fF6VqXvX3RkMzpp4ihTUgBPrh66vTf0= -github.com/NVIDIA/nvidia-container-toolkit v1.18.0/go.mod h1:ZxWSG7fnFo2Z7xSGtMyZVF7WnTbj1lgx4dMrBLUq90g= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -219,8 +217,8 @@ github.com/ulikunitz/xz v0.5.15 h1:9DNdB5s+SgV3bQ2ApL10xRc35ck0DuIX/isZvIk+ubY= github.com/ulikunitz/xz v0.5.15/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli/v2 v2.27.7 h1:bH59vdhbjLv3LAvIu6gd0usJHgoTTPhCFib8qqOwXYU= github.com/urfave/cli/v2 v2.27.7/go.mod h1:CyNAG/xg+iAOg0N4MPGZqVmv2rCoP267496AOXUZjA4= -github.com/urfave/cli/v3 v3.4.1 h1:1M9UOCy5bLmGnuu1yn3t3CB4rG79Rtoxuv1sPhnm6qM= -github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZtpYpo= +github.com/urfave/cli/v3 v3.5.0 h1:qCuFMmdayTF3zmjG8TSsoBzrDqszNrklYg2x3g4MSgw= +github.com/urfave/cli/v3 v3.5.0/go.mod h1:ysVLtOEmg2tOy6PknnYVhDoouyC/6N42TMeoMzskhso= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ= diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/create-dev-char-symlinks.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/create-dev-char-symlinks.go index aff17ada2..89ed6e4e6 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/create-dev-char-symlinks.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/create-dev-char-symlinks.go @@ -19,14 +19,12 @@ package devchar import ( "context" "fmt" - "os" - "path/filepath" "github.com/urfave/cli/v3" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" - "github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices" - "github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules" + "github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices" + "github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules" ) const ( @@ -115,10 +113,6 @@ func (m command) build() *cli.Command { } func (m command) validateFlags(cfg *config) error { - if cfg.createAll { - return fmt.Errorf("create-all and watch are mutually exclusive") - } - if cfg.loadKernelModules && !cfg.createAll { m.logger.Warning("load-kernel-modules is only applicable when create-all is set; ignoring") cfg.loadKernelModules = false @@ -155,7 +149,6 @@ func (m command) run(cfg *config) error { type linkCreator struct { logger logger.Interface - lister nodeLister driverRoot string devRoot string devCharPath string @@ -163,6 +156,8 @@ type linkCreator struct { createAll bool createDeviceNodes bool loadKernelModules bool + + devicesLib *nvdevices.Interface } // Creator is an interface for creating symlinks to /dev/nv* devices in /dev/char. @@ -174,6 +169,8 @@ type Creator interface { type Option func(*linkCreator) // NewSymlinkCreator creates a new linkCreator. +// +// Deprecated: Use the `nvdevices` package instead. func NewSymlinkCreator(opts ...Option) (Creator, error) { c := linkCreator{} for _, opt := range opts { @@ -192,52 +189,34 @@ func NewSymlinkCreator(opts ...Option) (Creator, error) { c.devCharPath = defaultDevCharPath } - if err := c.setup(); err != nil { - return nil, err - } - - if c.createAll { - lister, err := newAllPossible(c.logger, c.devRoot) - if err != nil { - return nil, fmt.Errorf("failed to create all possible device lister: %v", err) - } - c.lister = lister - } else { - c.lister = existing{c.logger, c.devRoot} - } - return c, nil -} - -func (m linkCreator) setup() error { - if !m.loadKernelModules && !m.createDeviceNodes { - return nil - } - - if m.loadKernelModules { + if c.loadKernelModules { modules := nvmodules.New( - nvmodules.WithLogger(m.logger), - nvmodules.WithDryRun(m.dryRun), - nvmodules.WithRoot(m.driverRoot), + nvmodules.WithLogger(c.logger), + nvmodules.WithDryRun(c.dryRun), + nvmodules.WithRoot(c.driverRoot), ) if err := modules.LoadAll(); err != nil { - return fmt.Errorf("failed to load NVIDIA kernel modules: %v", err) + return nil, fmt.Errorf("failed to load NVIDIA kernel modules: %v", err) } } - if m.createDeviceNodes { - devices, err := nvdevices.New( - nvdevices.WithLogger(m.logger), - nvdevices.WithDryRun(m.dryRun), - nvdevices.WithDevRoot(m.devRoot), - ) - if err != nil { - return err - } + devices, err := nvdevices.New( + nvdevices.WithLogger(c.logger), + nvdevices.WithDryRun(c.dryRun), + nvdevices.WithDevRoot(c.driverRoot), + ) + if err != nil { + return nil, err + } + c.devicesLib = devices + + if c.createDeviceNodes { if err := devices.CreateNVIDIAControlDevices(); err != nil { - return fmt.Errorf("failed to create NVIDIA device nodes: %v", err) + return nil, fmt.Errorf("failed to create NVIDIA device nodes: %v", err) } } - return nil + + return c, nil } // WithDriverRoot sets the driver root path. @@ -299,42 +278,5 @@ func WithCreateDeviceNodes(createDeviceNodes bool) Option { // CreateLinks creates symlinks for all NVIDIA device nodes found in the driver root. func (m linkCreator) CreateLinks() error { - deviceNodes, err := m.lister.DeviceNodes() - if err != nil { - return fmt.Errorf("failed to get device nodes: %v", err) - } - - if len(deviceNodes) != 0 && !m.dryRun { - err := os.MkdirAll(m.devCharPath, 0755) - if err != nil { - return fmt.Errorf("failed to create directory %s: %v", m.devCharPath, err) - } - } - - for _, deviceNode := range deviceNodes { - target := deviceNode.path - linkPath := filepath.Join(m.devCharPath, deviceNode.devCharName()) - - m.logger.Infof("Creating link %s => %s", linkPath, target) - if m.dryRun { - continue - } - - err = os.Symlink(target, linkPath) - if err != nil { - m.logger.Warningf("Could not create symlink: %v", err) - } - } - - return nil -} - -type deviceNode struct { - path string - major uint32 - minor uint32 -} - -func (d deviceNode) devCharName() string { - return fmt.Sprintf("%d:%d", d.major, d.minor) + return m.devicesLib.CreateDevCharSymlinks(m.devCharPath, !m.createAll) } diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing.go deleted file mode 100644 index d022a98fe..000000000 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing.go +++ /dev/null @@ -1,89 +0,0 @@ -/** -# Copyright (c) NVIDIA CORPORATION. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -**/ - -package devchar - -import ( - "path/filepath" - "strings" - - "golang.org/x/sys/unix" - - "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" - "github.com/NVIDIA/nvidia-container-toolkit/internal/lookup" -) - -type nodeLister interface { - DeviceNodes() ([]deviceNode, error) -} - -type existing struct { - logger logger.Interface - devRoot string -} - -// DeviceNodes returns a list of NVIDIA device nodes in the specified root. -// The nvidia-nvswitch* and nvidia-nvlink devices are excluded. -func (m existing) DeviceNodes() ([]deviceNode, error) { - locator := lookup.NewCharDeviceLocator( - lookup.WithLogger(m.logger), - lookup.WithRoot(m.devRoot), - lookup.WithOptional(true), - ) - - devices, err := locator.Locate("/dev/nvidia*") - if err != nil { - m.logger.Warningf("Error while locating device: %v", err) - } - - capDevices, err := locator.Locate("/dev/nvidia-caps/nvidia-*") - if err != nil { - m.logger.Warningf("Error while locating caps device: %v", err) - } - - if len(devices) == 0 && len(capDevices) == 0 { - m.logger.Infof("No NVIDIA devices found in %s", m.devRoot) - return nil, nil - } - - var deviceNodes []deviceNode - for _, d := range append(devices, capDevices...) { - if m.nodeIsBlocked(d) { - continue - } - var stat unix.Stat_t - err := unix.Stat(d, &stat) - if err != nil { - m.logger.Warningf("Could not stat device: %v", err) - continue - } - deviceNodes = append(deviceNodes, newDeviceNode(d, stat)) - } - - return deviceNodes, nil -} - -// nodeIsBlocked returns true if the specified device node should be ignored. -func (m existing) nodeIsBlocked(path string) bool { - blockedPrefixes := []string{"nvidia-fs", "nvidia-nvswitch", "nvidia-nvlink"} - nodeName := filepath.Base(path) - for _, prefix := range blockedPrefixes { - if strings.HasPrefix(nodeName, prefix) { - return true - } - } - return false -} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_linux.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_linux.go deleted file mode 100644 index 4aab942af..000000000 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_linux.go +++ /dev/null @@ -1,28 +0,0 @@ -/** -# Copyright (c) NVIDIA CORPORATION. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -**/ - -package devchar - -import "golang.org/x/sys/unix" - -func newDeviceNode(d string, stat unix.Stat_t) deviceNode { - deviceNode := deviceNode{ - path: d, - major: unix.Major(stat.Rdev), - minor: unix.Minor(stat.Rdev), - } - return deviceNode -} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_other.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_other.go deleted file mode 100644 index 9be96294b..000000000 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/existing_other.go +++ /dev/null @@ -1,30 +0,0 @@ -//go:build !linux - -/** -# Copyright (c) NVIDIA CORPORATION. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -**/ - -package devchar - -import "golang.org/x/sys/unix" - -func newDeviceNode(d string, stat unix.Stat_t) deviceNode { - deviceNode := deviceNode{ - path: d, - major: unix.Major(uint64(stat.Rdev)), - minor: unix.Minor(uint64(stat.Rdev)), - } - return deviceNode -} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/locator.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/locator.go index 9906327c4..b73d1d41f 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/locator.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/locator.go @@ -27,3 +27,13 @@ type Locator interface { // ErrNotFound indicates that a specified pattern or file could not be found. var ErrNotFound = errors.New("not found") + +type always string + +const Always = always("always") + +var _ Locator = (*always)(nil) + +func (l always) Locate(s string) ([]string, error) { + return []string{s}, nil +} diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/all.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/all.go similarity index 95% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/all.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/all.go index cafb8f9c7..c79ffc153 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks/all.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/all.go @@ -14,7 +14,7 @@ # limitations under the License. **/ -package devchar +package nvdevices import ( "fmt" @@ -34,6 +34,20 @@ type allPossible struct { migCaps nvcaps.MigCaps } +type nodeLister interface { + DeviceNodes() ([]deviceNode, error) +} + +type deviceNode struct { + path string + major uint32 + minor uint32 +} + +func (d deviceNode) devCharName() string { + return fmt.Sprintf("%d:%d", d.major, d.minor) +} + // newAllPossible returns a new allPossible device node lister. // This lister lists all possible device nodes for NVIDIA GPUs, control devices, and capability devices. func newAllPossible(logger logger.Interface, devRoot string) (nodeLister, error) { diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/devices.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/devices.go similarity index 68% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/devices.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/devices.go index f667f6b76..3d250cb1e 100644 --- a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/devices.go +++ b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/devices.go @@ -19,11 +19,13 @@ package nvdevices import ( "errors" "fmt" + "os" "path/filepath" "strings" "github.com/NVIDIA/nvidia-container-toolkit/internal/info/proc/devices" "github.com/NVIDIA/nvidia-container-toolkit/internal/logger" + "github.com/NVIDIA/nvidia-container-toolkit/internal/lookup" ) var errInvalidDeviceNode = errors.New("invalid device node") @@ -102,6 +104,67 @@ func (m *Interface) CreateNVIDIADevice(node string) error { return m.createDeviceNode(filepath.Join("dev", node), int(major), int(minor)) } +// CreateDevCharSymlinks creates symlinks at the specified path NVIDIA device nodes. +// If existingOnly is set to false, symlinks will be created for ALL possible devices. +func (m *Interface) CreateDevCharSymlinks(devCharPath string, existingOnly bool) error { + if devCharPath == "" || devCharPath == "/" { + return fmt.Errorf("invalid /dev/char path: %q", devCharPath) + } + lister, err := newAllPossible(m.logger, m.devRoot) + if err != nil { + return fmt.Errorf("failed to create all possible device lister: %v", err) + } + + deviceNodes, err := lister.DeviceNodes() + if err != nil { + return fmt.Errorf("failed to get device nodes: %v", err) + } + + var deviceNodeLocator lookup.Locator + if existingOnly { + deviceNodeLocator = lookup.NewCharDeviceLocator( + lookup.WithLogger(m.logger), + lookup.WithRoot(m.devRoot), + lookup.WithCount(1), + lookup.WithOptional(true), + ) + } else { + deviceNodeLocator = lookup.Always + } + + var parentCreated bool + for _, deviceNode := range deviceNodes { + target := deviceNode.path + // TODO: This assumes that the majors for the kernel modules align with + // the majors for the actual device nodes. + linkPath := filepath.Join(devCharPath, deviceNode.devCharName()) + + candidates, err := deviceNodeLocator.Locate(target) + if err != nil || len(candidates) == 0 { + m.logger.Debugf("Ignoring non-existing device node %q", target) + } + + m.logger.Infof("Creating link %s => %s", linkPath, target) + if m.dryRun { + continue + } + + if !parentCreated { + err := os.MkdirAll(devCharPath, 0755) + if err != nil { + return fmt.Errorf("failed to create directory %s: %v", devCharPath, err) + } + parentCreated = true + } + + if err := os.Symlink(target, linkPath); err != nil { + m.logger.Warningf("Could not create symlink: %v", err) + } + } + + return nil +} + // createDeviceNode creates the specified device node with the require major and minor numbers. // If a devRoot is configured, this is prepended to the path. func (m *Interface) createDeviceNode(path string, major int, minor int) error { diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/mknod.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/mknod.go similarity index 100% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/mknod.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/mknod.go diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/mknod_mock.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/mknod_mock.go similarity index 100% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/mknod_mock.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/mknod_mock.go diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/options.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/options.go similarity index 100% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices/options.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices/options.go diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/cmd.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/cmd.go similarity index 100% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/cmd.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/cmd.go diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/cmd_mock.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/cmd_mock.go similarity index 100% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/cmd_mock.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/cmd_mock.go diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/modules.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/modules.go similarity index 100% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/modules.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/modules.go diff --git a/vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/options.go b/vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/options.go similarity index 100% rename from vendor/github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules/options.go rename to vendor/github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules/options.go diff --git a/vendor/github.com/urfave/cli/v3/args.go b/vendor/github.com/urfave/cli/v3/args.go index 918afb2ed..e63e1f5e4 100644 --- a/vendor/github.com/urfave/cli/v3/args.go +++ b/vendor/github.com/urfave/cli/v3/args.go @@ -118,7 +118,7 @@ func (a *ArgumentBase[T, C, VC]) Parse(s []string) ([]string, error) { tracef("attempting arg%[1] parse", &a.Name) if len(s) > 0 { if err := value.Set(s[0]); err != nil { - return s, err + return s, fmt.Errorf("invalid value %q for argument %s: %v", s[0], a.Name, err) } *a.value = value.Get().(T) tracef("set arg%[1] one value", a.Name, *a.value) @@ -197,7 +197,7 @@ func (a *ArgumentsBase[T, C, VC]) Parse(s []string) ([]string, error) { tracef("attempting arg%[1] parse", &a.Name) for _, arg := range s { if err := value.Set(arg); err != nil { - return s, err + return s, fmt.Errorf("invalid value %q for argument %s: %v", arg, a.Name, err) } tracef("set arg%[1] one value", &a.Name, value.Get().(T)) a.values = append(a.values, value.Get().(T)) diff --git a/vendor/github.com/urfave/cli/v3/command.go b/vendor/github.com/urfave/cli/v3/command.go index d7b05637d..3eebbaff7 100644 --- a/vendor/github.com/urfave/cli/v3/command.go +++ b/vendor/github.com/urfave/cli/v3/command.go @@ -127,6 +127,14 @@ type Command struct { // Whether to read arguments from stdin // applicable to root command only ReadArgsFromStdin bool `json:"readArgsFromStdin"` + // StopOnNthArg provides v2-like behavior for specific commands by stopping + // flag parsing after N positional arguments are encountered. When set to N, + // all remaining arguments after the Nth positional argument will be treated + // as arguments, not flags. + // + // A value of 0 means all arguments are treated as positional (no flag parsing). + // A nil value means normal v3 flag parsing behavior (flags can appear anywhere). + StopOnNthArg *int `json:"stopOnNthArg"` // categories contains the categorized commands and is populated on app startup categories CommandCategories diff --git a/vendor/github.com/urfave/cli/v3/command_parse.go b/vendor/github.com/urfave/cli/v3/command_parse.go index 113065800..7e3e0ab35 100644 --- a/vendor/github.com/urfave/cli/v3/command_parse.go +++ b/vendor/github.com/urfave/cli/v3/command_parse.go @@ -89,6 +89,13 @@ func (cmd *Command) parseFlags(args Args) (Args, error) { return &stringSliceArgs{posArgs}, nil } + // Check if we've reached the Nth argument and should stop flag parsing + if cmd.StopOnNthArg != nil && len(posArgs) == *cmd.StopOnNthArg { + // Append current arg and all remaining args without parsing + posArgs = append(posArgs, rargs[0:]...) + return &stringSliceArgs{posArgs}, nil + } + // handle positional args if firstArg[0] != '-' { // positional argument probably diff --git a/vendor/github.com/urfave/cli/v3/command_run.go b/vendor/github.com/urfave/cli/v3/command_run.go index 6b2abc1b9..855eb9732 100644 --- a/vendor/github.com/urfave/cli/v3/command_run.go +++ b/vendor/github.com/urfave/cli/v3/command_run.go @@ -92,13 +92,18 @@ outer: // definitions and the matching Action functions are run. func (cmd *Command) Run(ctx context.Context, osArgs []string) (deferErr error) { _, deferErr = cmd.run(ctx, osArgs) - return + return deferErr } func (cmd *Command) run(ctx context.Context, osArgs []string) (_ context.Context, deferErr error) { tracef("running with arguments %[1]q (cmd=%[2]q)", osArgs, cmd.Name) cmd.setupDefaults(osArgs) + // Validate StopOnNthArg + if cmd.StopOnNthArg != nil && *cmd.StopOnNthArg < 0 { + return ctx, fmt.Errorf("StopOnNthArg must be non-negative, got %d", *cmd.StopOnNthArg) + } + if v, ok := ctx.Value(commandContextKey).(*Command); ok { tracef("setting parent (cmd=%[1]q) command from context.Context value (cmd=%[2]q)", v.Name, cmd.Name) cmd.parent = v diff --git a/vendor/github.com/urfave/cli/v3/docs.go b/vendor/github.com/urfave/cli/v3/docs.go index 42cad718b..8ecdfc835 100644 --- a/vendor/github.com/urfave/cli/v3/docs.go +++ b/vendor/github.com/urfave/cli/v3/docs.go @@ -14,7 +14,7 @@ func prefixFor(name string) (prefix string) { prefix = "--" } - return + return prefix } // Returns the placeholder, if any, and the unquoted usage string. @@ -107,9 +107,12 @@ func stringifyFlag(f Flag) string { // don't print default text for required flags if rf, ok := f.(RequiredFlag); !ok || !rf.IsRequired() { - isVisible := df.IsDefaultVisible() - if s := df.GetDefaultText(); isVisible && s != "" { - defaultValueString = fmt.Sprintf(formatDefault("%s"), s) + if df.IsDefaultVisible() { + if s := df.GetDefaultText(); s != "" { + defaultValueString = fmt.Sprintf(formatDefault("%s"), s) + } else if df.TakesValue() && df.GetValue() != "" { + defaultValueString = fmt.Sprintf(formatDefault("%s"), df.GetValue()) + } } } diff --git a/vendor/github.com/urfave/cli/v3/flag_impl.go b/vendor/github.com/urfave/cli/v3/flag_impl.go index 2495b6efa..d4390ee2d 100644 --- a/vendor/github.com/urfave/cli/v3/flag_impl.go +++ b/vendor/github.com/urfave/cli/v3/flag_impl.go @@ -70,10 +70,8 @@ type FlagBase[T any, C any, VC ValueCreator[T, C]] struct { // GetValue returns the flags value as string representation and an empty // string if the flag takes no value at all. func (f *FlagBase[T, C, V]) GetValue() string { - if !f.TakesValue() { - return "" - } - return fmt.Sprintf("%v", f.Value) + var v V + return v.ToString(f.Value) } // TypeName returns the type of the flag. @@ -253,11 +251,7 @@ func (f *FlagBase[T, C, V]) TakesValue() bool { // GetDefaultText returns the default text for this flag func (f *FlagBase[T, C, V]) GetDefaultText() string { - if f.DefaultText != "" { - return f.DefaultText - } - var v V - return v.ToString(f.Value) + return f.DefaultText } // RunAction executes flag action if set diff --git a/vendor/github.com/urfave/cli/v3/godoc-current.txt b/vendor/github.com/urfave/cli/v3/godoc-current.txt index bf43768cf..46fb4d43a 100644 --- a/vendor/github.com/urfave/cli/v3/godoc-current.txt +++ b/vendor/github.com/urfave/cli/v3/godoc-current.txt @@ -528,6 +528,14 @@ type Command struct { // Whether to read arguments from stdin // applicable to root command only ReadArgsFromStdin bool `json:"readArgsFromStdin"` + // StopOnNthArg provides v2-like behavior for specific commands by stopping + // flag parsing after N positional arguments are encountered. When set to N, + // all remaining arguments after the Nth positional argument will be treated + // as arguments, not flags. + // + // A value of 0 means all arguments are treated as positional (no flag parsing). + // A nil value means normal v3 flag parsing behavior (flags can appear anywhere). + StopOnNthArg *int `json:"stopOnNthArg"` // Has unexported fields. } diff --git a/vendor/github.com/urfave/cli/v3/mkdocs-reqs.txt b/vendor/github.com/urfave/cli/v3/mkdocs-reqs.txt deleted file mode 100644 index 365d864c7..000000000 --- a/vendor/github.com/urfave/cli/v3/mkdocs-reqs.txt +++ /dev/null @@ -1,5 +0,0 @@ -mkdocs-git-revision-date-localized-plugin~=1.2 -mkdocs-material~=9.5 -mkdocs~=1.6 -mkdocs-redirects~=1.2 -pygments~=2.18 diff --git a/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt b/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt new file mode 100644 index 000000000..4c9d877a6 --- /dev/null +++ b/vendor/github.com/urfave/cli/v3/mkdocs-requirements.txt @@ -0,0 +1,5 @@ +mkdocs-git-revision-date-localized-plugin==1.4.7 +mkdocs-material==9.6.22 +mkdocs==1.6.1 +mkdocs-redirects==1.2.2 +pygments==2.19.2 diff --git a/vendor/github.com/urfave/cli/v3/mkdocs.yml b/vendor/github.com/urfave/cli/v3/mkdocs.yml index 97bc4ad58..e1eac9587 100644 --- a/vendor/github.com/urfave/cli/v3/mkdocs.yml +++ b/vendor/github.com/urfave/cli/v3/mkdocs.yml @@ -1,7 +1,7 @@ # NOTE: the mkdocs dependencies will need to be installed out of # band until this whole thing gets more automated: # -# pip install -r mkdocs-reqs.txt +# pip install -r mkdocs-requirements.txt # site_name: urfave/cli diff --git a/vendor/github.com/urfave/cli/v3/template.go b/vendor/github.com/urfave/cli/v3/template.go index 29c8e8c71..dd144e77d 100644 --- a/vendor/github.com/urfave/cli/v3/template.go +++ b/vendor/github.com/urfave/cli/v3/template.go @@ -2,7 +2,7 @@ package cli var ( helpNameTemplate = `{{$v := offset .FullName 6}}{{wrap .FullName 3}}{{if .Usage}} - {{wrap .Usage $v}}{{end}}` - argsTemplate = `{{if .Arguments}}{{range .Arguments}}{{.Usage}}{{end}}{{end}}` + argsTemplate = `{{if .Arguments}}{{range .Arguments}}{{.Usage}} {{end}}{{end}}` usageTemplate = `{{if .UsageText}}{{wrap .UsageText 3}}{{else}}{{.FullName}}{{if .VisibleFlags}} [options]{{end}}{{if .VisibleCommands}} [command [command options]]{{end}}{{if .ArgsUsage}} {{.ArgsUsage}}{{else}}{{if .Arguments}} {{template "argsTemplate" .}}{{end}}{{end}}{{end}}` descriptionTemplate = `{{wrap .Description 3}}` authorsTemplate = `{{with $length := len .Authors}}{{if ne 1 $length}}S{{end}}{{end}}: diff --git a/vendor/modules.txt b/vendor/modules.txt index e4eb69252..eea1d3547 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -35,7 +35,7 @@ github.com/NVIDIA/k8s-kata-manager/api/v1alpha1/config github.com/NVIDIA/k8s-operator-libs/api/upgrade/v1alpha1 github.com/NVIDIA/k8s-operator-libs/pkg/consts github.com/NVIDIA/k8s-operator-libs/pkg/upgrade -# github.com/NVIDIA/nvidia-container-toolkit v1.18.0 +# github.com/NVIDIA/nvidia-container-toolkit v1.18.0 => ../container-toolkit ## explicit; go 1.24.0 github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk/system/create-dev-char-symlinks github.com/NVIDIA/nvidia-container-toolkit/internal/info/proc/devices @@ -44,8 +44,8 @@ github.com/NVIDIA/nvidia-container-toolkit/internal/logger github.com/NVIDIA/nvidia-container-toolkit/internal/lookup github.com/NVIDIA/nvidia-container-toolkit/internal/lookup/symlinks github.com/NVIDIA/nvidia-container-toolkit/internal/nvcaps -github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvdevices -github.com/NVIDIA/nvidia-container-toolkit/internal/system/nvmodules +github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvdevices +github.com/NVIDIA/nvidia-container-toolkit/pkg/system/nvmodules # github.com/beorn7/perks v1.0.1 ## explicit; go 1.11 github.com/beorn7/perks/quantile @@ -381,7 +381,7 @@ github.com/ulikunitz/xz/lzma # github.com/urfave/cli/v2 v2.27.7 ## explicit; go 1.18 github.com/urfave/cli/v2 -# github.com/urfave/cli/v3 v3.4.1 +# github.com/urfave/cli/v3 v3.5.0 ## explicit; go 1.22 github.com/urfave/cli/v3 # github.com/x448/float16 v0.8.4 @@ -1185,3 +1185,4 @@ sigs.k8s.io/structured-merge-diff/v6/value sigs.k8s.io/yaml sigs.k8s.io/yaml/goyaml.v2 sigs.k8s.io/yaml/goyaml.v3 +# github.com/NVIDIA/nvidia-container-toolkit => ../container-toolkit