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

return error if libcontainer desroy failed #4090

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ checkpointed.`,
err = container.Checkpoint(options)
if err == nil && !(options.LeaveRunning || options.PreDump) {
// Destroy the container unless we tell CRIU to keep it.
destroy(container)
_ = destroy(container)
}
return err
},
Expand Down
6 changes: 4 additions & 2 deletions delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func killContainer(container *libcontainer.Container) error {
for i := 0; i < 100; i++ {
time.Sleep(100 * time.Millisecond)
if err := container.Signal(unix.Signal(0)); err != nil {
destroy(container)
_ = destroy(container)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why ignore the error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep others unchanged to make the minimum changes.

return nil
}
}
Expand Down Expand Up @@ -72,7 +72,9 @@ status of "ubuntu01" as "stopped" the following will delete resources held for
}
switch s {
case libcontainer.Stopped:
destroy(container)
if err := destroy(container); err != nil {
return err
}
case libcontainer.Created:
return killContainer(container)
default:
Expand Down
6 changes: 4 additions & 2 deletions utils_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,12 @@ func newProcess(p specs.Process) (*libcontainer.Process, error) {
return lp, nil
}

func destroy(container *libcontainer.Container) {
func destroy(container *libcontainer.Container) error {
if err := container.Destroy(); err != nil {
logrus.Error(err)
return err
}
return nil
}

// setupIO modifies the given process config according to the options.
Expand Down Expand Up @@ -293,7 +295,7 @@ func (r *runner) run(config *specs.Process) (int, error) {

func (r *runner) destroy() {
if r.shouldDestroy {
destroy(r.container)
_ = destroy(r.container)
}
}

Expand Down
Loading