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

Commit

Permalink
agent: add support for online memory and cpu separately.
Browse files Browse the repository at this point in the history
In func OnlineCPUMem, cpu is always onlined,
which is not expected. So we add "CpuOnly"
field to support separating memory and cpu online.

Fixes #332

Signed-off-by: Clare Chen <[email protected]>
Signed-off-by: Zichang Lin <[email protected]>
  • Loading branch information
cedriccchen committed Aug 28, 2018
1 parent 46396d2 commit b1c2ad8
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 154 deletions.
16 changes: 10 additions & 6 deletions grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,25 @@ func updateContainerCpuset(cgroupPath string, newCpuset string, cookies cookie)
}

func (a *agentGRPC) onlineCPUMem(req *pb.OnlineCPUMemRequest) error {
if req.NbCpus <= 0 {
if req.NbCpus == 0 && req.CpuOnly {
return handleError(req.Wait, fmt.Errorf("requested number of CPUs '%d' must be greater than 0", req.NbCpus))
}

// we are going to update the containers of the sandbox, we have to lock it
a.sandbox.Lock()
defer a.sandbox.Unlock()

agentLog.WithField("vcpus-to-connect", req.NbCpus).Debug("connecting vCPUs")
if err := onlineCPUResources(req.NbCpus); err != nil {
return handleError(req.Wait, err)
if req.NbCpus > 0 {
agentLog.WithField("vcpus-to-connect", req.NbCpus).Debug("connecting vCPUs")
if err := onlineCPUResources(req.NbCpus); err != nil {
return handleError(req.Wait, err)
}
}

if err := onlineMemResources(); err != nil {
return handleError(req.Wait, err)
if !req.CpuOnly {
if err := onlineMemResources(); err != nil {
return handleError(req.Wait, err)
}
}

// At this point all CPUs have been connected, we need to know
Expand Down
Loading

0 comments on commit b1c2ad8

Please sign in to comment.