From de44258b7fa68a9b3acaabc001227a0c0da916d9 Mon Sep 17 00:00:00 2001 From: Roman Dodin Date: Sat, 7 Dec 2024 15:28:38 +0100 Subject: [PATCH] Properly use the skip binds check (#2337) --- clab/config.go | 9 +++++++-- cmd/destroy.go | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/clab/config.go b/clab/config.go index 3542455cc..04e62160f 100644 --- a/clab/config.go +++ b/clab/config.go @@ -499,7 +499,12 @@ func (c *CLab) verifyContainersUniqueness(ctx context.Context) error { // it allows host path to have `~` and relative path to an absolute path // the list of binds will be changed in place. // if the host path doesn't exist, the error will be returned. -func (c *CLab) resolveBindPaths(binds []string, nodedir string) error { +func (c *CLab) resolveBindPaths(binds []string, nodeDir string) error { + // checks are skipped when, for example, the destroy operation is run + if !c.checkBindsPaths { + return nil + } + for i := range binds { // host path is a first element in a /hostpath:/remotepath(:options) string elems := strings.Split(binds[i], ":") @@ -510,7 +515,7 @@ func (c *CLab) resolveBindPaths(binds []string, nodedir string) error { continue } // replace special variable - r := strings.NewReplacer(clabDirVar, c.TopoPaths.TopologyLabDir(), nodeDirVar, nodedir) + r := strings.NewReplacer(clabDirVar, c.TopoPaths.TopologyLabDir(), nodeDirVar, nodeDir) hp := r.Replace(elems[0]) hp = utils.ResolvePath(hp, c.TopoPaths.TopologyFileDir()) diff --git a/cmd/destroy.go b/cmd/destroy.go index 0f13f2d58..1b44a7608 100644 --- a/cmd/destroy.go +++ b/cmd/destroy.go @@ -185,6 +185,9 @@ func listContainers(ctx context.Context, topo string) ([]runtime.GenericContaine opts := []clab.ClabOption{ clab.WithRuntime(rt, runtimeConfig), clab.WithTimeout(timeout), + // when listing containers we don't care if binds are accurate + // since this function is used in the destroy process + clab.WithSkippedBindsPathsCheck(), } // filter to list all containerlab containers