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

podman machine rm not locking correctly #20950

Closed
Luap99 opened this issue Dec 8, 2023 · 2 comments
Closed

podman machine rm not locking correctly #20950

Luap99 opened this issue Dec 8, 2023 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine stale-issue

Comments

@Luap99
Copy link
Member

Luap99 commented Dec 8, 2023

podman machine uses a lockfile to synchronize access for the VM.

However if we look at the podman machine rm logic it does lock in this function but only to get the current file paths. Then it returns the paths in a function that is returned. The cli remove code then waits for the user to confirm the removal before deleting the files.
This means the actually removal of the files is not locked and it could lead to another machine command run in parallel and then having files removed while being used.

This problems seem to effect all providers.

func (v *MachineVM) Remove(_ string, opts machine.RemoveOptions) (string, func() error, error) {
var (
files []string
)
v.lock.Lock()
defer v.lock.Unlock()
// cannot remove a running vm unless --force is used
state, err := v.State(false)
if err != nil {
return "", nil, err
}
if state == machine.Running {
if !opts.Force {
return "", nil, &machine.ErrVMRunningCannotDestroyed{Name: v.Name}
}
err := v.stopLocked()
if err != nil {
return "", nil, err
}
}
files, err = v.collectFilesToDestroy(opts)
if err != nil {
return "", nil, err
}
confirmationMessage := "\nThe following files will be deleted:\n\n"
for _, msg := range files {
confirmationMessage += msg + "\n"
}
v.removeQMPMonitorSocketAndVMPidFile()
confirmationMessage += "\n"
return confirmationMessage, func() error {
machine.RemoveFilesAndConnections(files, v.Name, v.Name+"-root")
return nil
}, nil
}

@Luap99 Luap99 added kind/bug Categorizes issue or PR as related to a bug. machine labels Dec 8, 2023
Copy link

github-actions bot commented Jan 8, 2024

A friendly reminder that this issue had no activity for 30 days.

@Luap99
Copy link
Member Author

Luap99 commented Apr 4, 2024

was fixed in 35133c8

@Luap99 Luap99 closed this as completed Apr 4, 2024
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Jul 4, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Jul 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine stale-issue
Projects
None yet
Development

No branches or pull requests

1 participant