agent: add cgroup v2 support

This PR add basic cgroup v2 support for agent.

Fixes: #146, #357

Signed-off-by: bin liu <bin@hyper.sh>
This commit is contained in:
bin liu
2020-08-24 19:44:16 +08:00
parent 63138a4f28
commit 15065e4472
15 changed files with 1454 additions and 1338 deletions

View File

@@ -146,7 +146,7 @@ func watchOOMEvents(ctx context.Context, s *service) {
// If the GetOOMEvent call is not implemented, then the agent is most likely an older version,
// stop attempting to get OOM events.
// for rust agent, the response code is not found
if isGRPCErrorCode(codes.NotFound, err) {
if isGRPCErrorCode(codes.NotFound, err) || err.Error() == "Dead agent" {
return
}
continue

View File

@@ -1203,10 +1203,10 @@ func (s *Sandbox) CreateContainer(contConfig ContainerConfig) (VCContainer, erro
// Rollback if error happens.
if err != nil {
logger := s.Logger().WithFields(logrus.Fields{"container-id": c.id, "sandox-id": s.id, "rollback": true})
logger.Warning("Cleaning up partially created container")
logger.WithError(err).Error("Cleaning up partially created container")
if err2 := c.stop(true); err2 != nil {
logger.WithError(err2).Warning("Could not delete container")
logger.WithError(err2).Error("Could not delete container")
}
logger.Debug("Removing stopped container from sandbox store")
@@ -1894,9 +1894,11 @@ func (s *Sandbox) updateResources() error {
return err
}
s.Logger().Debugf("Request to hypervisor to update oldCPUs/newCPUs: %d/%d", oldCPUs, newCPUs)
// If the CPUs were increased, ask agent to online them
if oldCPUs < newCPUs {
vcpusAdded := newCPUs - oldCPUs
s.Logger().Debugf("Request to onlineCPUMem with %d CPUs", vcpusAdded)
if err := s.agent.onlineCPUMem(vcpusAdded, true); err != nil {
return err
}