Skip to content

Commit

Permalink
grpc: sandbox: add container when is fully created.
Browse files Browse the repository at this point in the history
Add container to sandbox list until it is created.

This commit makes sure to add the container to the sandbox until it is
created.

This helps to avoid other go routines uses the container structure with
nil pointers (because is not fully created).

Fixes: kata-containers#417

Signed-off-by: Jose Carlos Venegas Munoz <[email protected]>
  • Loading branch information
jcvenegas committed Dec 7, 2018
1 parent 0ff3006 commit 34b7454
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ func (a *agentGRPC) finishCreateContainer(ctr *container, req *pb.CreateContaine
return emptyResp, err
}

// Make sure add Container to Sandbox, before call updateSharedPidNs
a.sandbox.setContainer(req.ContainerId, ctr)
if err := a.updateSharedPidNs(ctr); err != nil {
return emptyResp, err
}
Expand Down Expand Up @@ -606,8 +608,6 @@ func (a *agentGRPC) CreateContainer(ctx context.Context, req *pb.CreateContainer
useSandboxPidNs: req.SandboxPidns,
}

a.sandbox.setContainer(req.ContainerId, ctr)

// In case the container creation failed, make sure we cleanup
// properly by rolling back the actions previously performed.
defer func() {
Expand Down

0 comments on commit 34b7454

Please sign in to comment.