From dfc6dc0332a4d59b16765bff22b356b78a1c066b Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Sat, 26 Oct 2024 21:28:17 +0200 Subject: [PATCH] [no-relnote] Remove unused TryDelete function Signed-off-by: Evan Lezar --- tools/container/toolkit/toolkit.go | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/tools/container/toolkit/toolkit.go b/tools/container/toolkit/toolkit.go index 9b97b419..4aa04fc9 100644 --- a/tools/container/toolkit/toolkit.go +++ b/tools/container/toolkit/toolkit.go @@ -24,7 +24,6 @@ import ( "path/filepath" "strings" - log "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" "tags.cncf.io/container-device-interface/pkg/cdi" "tags.cncf.io/container-device-interface/pkg/parser" @@ -44,8 +43,6 @@ const ( nvidiaContainerToolkitConfigSource = "/etc/nvidia-container-runtime/config.toml" configFilename = "config.toml" - - toolkitPidFilename = "toolkit.pid" ) type Options struct { @@ -257,33 +254,6 @@ func ValidateOptions(opts *Options, toolkitRoot string) error { return nil } -// TryDelete attempts to remove the specified toolkit folder. -// A toolkit.pid file -- if present -- is skipped. -func TryDelete(cli *cli.Context, toolkitRoot string) error { - log.Infof("Attempting to delete NVIDIA container toolkit from '%v'", toolkitRoot) - - contents, err := os.ReadDir(toolkitRoot) - if err != nil && errors.Is(err, os.ErrNotExist) { - return nil - } else if err != nil { - return fmt.Errorf("failed to read the contents of %v: %w", toolkitRoot, err) - } - - for _, content := range contents { - if content.Name() == toolkitPidFilename { - continue - } - name := filepath.Join(toolkitRoot, content.Name()) - if err := os.RemoveAll(name); err != nil { - log.Warningf("could not remove %v: %v", name, err) - } - } - if err := os.RemoveAll(toolkitRoot); err != nil { - log.Warningf("could not remove %v: %v", toolkitRoot, err) - } - return nil -} - // Install installs the components of the NVIDIA container toolkit. // The specified sourceRoot is searched for the components to install. // Any existing installation is removed.