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

Commit

Permalink
clh: Report warning when requested vCPUs exceeds maxVCPU allowed
Browse files Browse the repository at this point in the history
To have a consistent behavior of CPU hotplug with qemu in clh, we should
only report warning instead of errors when the requested vCPUs exceeds
the maximum number of vCPUs allowed.

Fixes: #2551

Signed-off-by: Bo Chen <[email protected]>
  • Loading branch information
likebreath committed Mar 27, 2020
1 parent 2a19de8 commit 669b6e3
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions virtcontainers/clh.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,15 +514,14 @@ func (clh *cloudHypervisor) resizeVCPUs(reqVCPUs uint32) (currentVCPUs uint32, n
clh.Logger().WithField("function", "resizeVCPUs").Debugf("Cannot resize vCPU to 0")
return currentVCPUs, newVCPUs, fmt.Errorf("Cannot resize vCPU to 0")
}
if reqVCPUs > clh.config.DefaultMaxVCPUs || reqVCPUs > uint32(info.Config.Cpus.MaxVcpus) {
if reqVCPUs > uint32(info.Config.Cpus.MaxVcpus) {
clh.Logger().WithFields(log.Fields{
"function": "resizeVCPUs",
"reqVCPUs": reqVCPUs,
"configDefaultMaxVCPUs": clh.config.DefaultMaxVCPUs,
"clhMaxVCPUs": info.Config.Cpus.MaxVcpus,
}).Debug("exceeding the maxVCPUs")
return currentVCPUs, newVCPUs, fmt.Errorf("Cannot resize vCPU to %d: exceeding the maximum amount of vCPUs (%d or %d)",
reqVCPUs, clh.config.DefaultMaxVCPUs, info.Config.Cpus.MaxVcpus)
"function": "resizeVCPUs",
"reqVCPUs": reqVCPUs,
"clhMaxVCPUs": info.Config.Cpus.MaxVcpus,
}).Warn("exceeding the 'clhMaxVCPUs' (resizing to 'clhMaxVCPUs')")

reqVCPUs = uint32(info.Config.Cpus.MaxVcpus)
}

// Resize (hot-plug) vCPUs via HTTP API
Expand Down

0 comments on commit 669b6e3

Please sign in to comment.