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

Avoid sending a signal to the container during checkpointing #11054

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions runsc/boot/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ go_library(
"//pkg/metric",
"//pkg/rand",
"//pkg/refs",
"//pkg/atomicbitops",
"//pkg/sentry/arch",
"//pkg/sentry/arch:registers_go_proto",
"//pkg/sentry/control",
Expand Down
10 changes: 10 additions & 0 deletions runsc/boot/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

specs "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/sys/unix"
"gvisor.dev/gvisor/pkg/atomicbitops"
"gvisor.dev/gvisor/pkg/cleanup"
"gvisor.dev/gvisor/pkg/context"
"gvisor.dev/gvisor/pkg/control/server"
Expand Down Expand Up @@ -255,6 +256,9 @@ type containerManager struct {
// restorer is set when the sandbox in being restored. It stores the state
// of all containers and perform all actions required by restore.
restorer *restorer

// inCheckpointing indicates that the sandbox is in checkpointing
inCheckpointing atomicbitops.Int32
}

// StartRoot will start the root container process.
Expand Down Expand Up @@ -452,6 +456,9 @@ func (cm *containerManager) ExecuteAsync(args *control.ExecArgs, pid *int32) err
// Checkpoint pauses a sandbox and saves its state.
func (cm *containerManager) Checkpoint(o *control.SaveOpts, _ *struct{}) error {
log.Debugf("containerManager.Checkpoint")
cm.inCheckpointing.CompareAndSwap(0, -1)
defer cm.inCheckpointing.CompareAndSwap(-1, 0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't look right. Why do we use CompareAndSwap here? Can more than one checkpoint operation run concurrently? If the answer is yest, so we probably need to use cm.inCheckpointing.Add(1); defer cm.inCheckpointing.Add(-1).


return cm.l.save(o)
}

Expand Down Expand Up @@ -788,6 +795,9 @@ type SignalArgs struct {
// process group.
func (cm *containerManager) Signal(args *SignalArgs, _ *struct{}) error {
log.Debugf("containerManager.Signal: cid: %s, PID: %d, signal: %d, mode: %v", args.CID, args.PID, args.Signo, args.Mode)
if cm.inCheckpointing.Load() != 0 {
return nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't look right either. We can't return success if the signal hasn't been sent....

}
return cm.l.signal(args.CID, args.PID, args.Signo, args.Mode)
}

Expand Down