Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #91 from devimc/cpu/fixRaceCondition
Browse files Browse the repository at this point in the history
virtcontainers: agent: fix CPU hot plug race condition
  • Loading branch information
Julio Montes authored Apr 13, 2018
2 parents f88086f + da6d284 commit 0f9defd
Show file tree
Hide file tree
Showing 8 changed files with 171 additions and 85 deletions.
4 changes: 2 additions & 2 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

[[constraint]]
name = "github.com/kata-containers/agent"
revision = "c8199f60759a1d52932df37a1af710cdeada8c81"
revision = "a6166b794d3c5747cd8da1f943aec64c70f08afe"

[[constraint]]
name = "github.com/containerd/cri-containerd"
Expand Down

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion virtcontainers/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,5 +175,6 @@ type agent interface {

// onlineCPUMem will online CPUs and Memory inside the Sandbox.
// This function should be called after hot adding vCPUs or Memory.
onlineCPUMem() error
// cpus specifies the number of CPUs that were added and the agent should online
onlineCPUMem(cpus uint32) error
}
2 changes: 1 addition & 1 deletion virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ func (c *Container) addResources() error {
return err
}

return c.sandbox.agent.onlineCPUMem()
return c.sandbox.agent.onlineCPUMem(uint32(vCPUs))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/hyperstart_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ func (h *hyper) sendCmd(proxyCmd hyperstartProxyCmd) (interface{}, error) {
return h.client.HyperWithTokens(proxyCmd.cmd, tokens, proxyCmd.message)
}

func (h *hyper) onlineCPUMem() error {
func (h *hyper) onlineCPUMem(cpus uint32) error {
// cc-agent uses udev to online CPUs automatically
return nil
}
7 changes: 5 additions & 2 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,11 @@ func (k *kataAgent) processListContainer(sandbox Sandbox, c Container, options P
return nil, nil
}

func (k *kataAgent) onlineCPUMem() error {
req := &grpc.OnlineCPUMemRequest{}
func (k *kataAgent) onlineCPUMem(cpus uint32) error {
req := &grpc.OnlineCPUMemRequest{
Wait: false,
NbCpus: cpus,
}

_, err := k.sendReq(req)
return err
Expand Down
2 changes: 1 addition & 1 deletion virtcontainers/noop_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ func (n *noopAgent) processListContainer(sandbox Sandbox, c Container, options P
}

// onlineCPUMem is the Noop agent Container online CPU and Memory implementation. It does nothing.
func (n *noopAgent) onlineCPUMem() error {
func (n *noopAgent) onlineCPUMem(cpus uint32) error {
return nil
}

0 comments on commit 0f9defd

Please sign in to comment.