Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly use the skip binds check #2337

Merged
merged 1 commit into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading