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 #68 from devimc/agent/onlineCPUs
Browse files Browse the repository at this point in the history
virtcontainers: agent: use onlineCPUMem to online vCPUs
  • Loading branch information
bergwolf authored Mar 21, 2018
2 parents 397905f + 0916bb6 commit 6d05197
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions virtcontainers/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,8 @@ type agent interface {

// processListContainer will list the processes running inside the container
processListContainer(pod Pod, c Container, options ProcessListOptions) (ProcessList, error)

// onlineCPUMem will online CPUs and Memory inside the Pod.
// This function should be called after hot adding vCPUs or Memory.
onlineCPUMem() error
}
2 changes: 2 additions & 0 deletions virtcontainers/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,8 @@ func (c *Container) addResources() error {
if err := c.pod.hypervisor.hotplugAddDevice(uint32(vCPUs), cpuDev); err != nil {
return err
}

return c.pod.agent.onlineCPUMem()
}

return nil
Expand Down
5 changes: 5 additions & 0 deletions virtcontainers/hyperstart_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,8 @@ func (h *hyper) sendCmd(proxyCmd hyperstartProxyCmd) (interface{}, error) {

return h.client.HyperWithTokens(proxyCmd.cmd, tokens, proxyCmd.message)
}

func (h *hyper) onlineCPUMem() error {
// cc-agent uses udev to online CPUs automatically
return nil
}
9 changes: 9 additions & 0 deletions virtcontainers/kata_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,13 @@ func (k *kataAgent) processListContainer(pod Pod, c Container, options ProcessLi
return nil, nil
}

func (k *kataAgent) onlineCPUMem() error {
req := &grpc.OnlineCPUMemRequest{}

_, err := k.sendReq(req)
return err
}

func (k *kataAgent) connect() error {
if k.client != nil {
return nil
Expand Down Expand Up @@ -836,6 +843,8 @@ func (k *kataAgent) sendReq(request interface{}) (interface{}, error) {
case *grpc.UpdateInterfaceRequest:
ifc, err := k.client.UpdateInterface(context.Background(), req)
return ifc, err
case *grpc.OnlineCPUMemRequest:
return k.client.OnlineCPUMem(context.Background(), req)
default:
return nil, fmt.Errorf("Unknown gRPC type %T", req)
}
Expand Down
5 changes: 5 additions & 0 deletions virtcontainers/noop_agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,8 @@ func (n *noopAgent) killContainer(pod Pod, c Container, signal syscall.Signal, a
func (n *noopAgent) processListContainer(pod Pod, c Container, options ProcessListOptions) (ProcessList, error) {
return nil, nil
}

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

0 comments on commit 6d05197

Please sign in to comment.