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

[release-1.10] server: fix race between container create and cadvisor asking for info #1616

Merged
merged 1 commit into from
Jun 17, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions server/container_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,14 +702,25 @@ func (s *Server) CreateContainer(ctx context.Context, req *pb.CreateContainerReq
}
}()

if err = s.Runtime().CreateContainer(container, sb.CgroupParent()); err != nil {
return nil, err
}

s.addContainer(container)
defer func() {
if err != nil {
s.removeContainer(container)
}
}()

if err = s.CtrIDIndex().Add(containerID); err != nil {
s.removeContainer(container)
return nil, err
}
defer func() {
if err != nil {
if err2 := s.CtrIDIndex().Delete(containerID); err2 != nil {
logrus.Warnf("couldn't delete ctr id %s from idIndex", containerID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Add err2 string to message

Copy link
Member Author

Choose a reason for hiding this comment

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

we're not doing that in other cases because I believe the error is not saying anything useful (just something about the trunc/patricia index).

}
}
}()

if err = s.Runtime().CreateContainer(container, sb.CgroupParent()); err != nil {
return nil, err
}

Expand Down
9 changes: 7 additions & 2 deletions server/sandbox_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,12 +573,17 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
return nil, fmt.Errorf("failed to write runtime configuration for pod sandbox %s(%s): %v", sb.Name(), id, err)
}

s.addInfraContainer(container)
defer func() {
if err != nil {
s.removeInfraContainer(container)
}
}()

if err = s.runContainer(container, sb.CgroupParent()); err != nil {
return nil, err
}

s.addInfraContainer(container)

s.ContainerStateToDisk(container)

if !s.config.Config.ManageNetworkNSLifecycle {
Expand Down