Skip to content

Commit

Permalink
Properly use the skip binds check (#2337)
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt authored Dec 7, 2024
1 parent c25b2f4 commit de44258
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 7 additions & 2 deletions clab/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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], ":")
Expand All @@ -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())

Expand Down
3 changes: 3 additions & 0 deletions cmd/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit de44258

Please sign in to comment.