Skip to content

Commit

Permalink
Merge pull request #3956 from sethp-nr/fix/eventfd-leak
Browse files Browse the repository at this point in the history
fix: eventfd leak
  • Loading branch information
AkihiroSuda committed Jan 14, 2020
2 parents bb9d4e8 + 6650858 commit c55bd87
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 25 deletions.
14 changes: 7 additions & 7 deletions runtime/v2/runc/v1/service.go
Expand Up @@ -271,15 +271,15 @@ func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (*taskAPI.
s.eventSendMu.Unlock()
return nil, errdefs.ToGRPC(err)
}
if cg, ok := container.Cgroup().(cgroups.Cgroup); ok {
if err := s.ep.Add(container.ID, cg); err != nil {
logrus.WithError(err).Error("add cg to OOM monitor")
}
} else {
logrus.WithError(errdefs.ErrNotImplemented).Error("add cg to OOM monitor")
}
switch r.ExecID {
case "":
if cg, ok := container.Cgroup().(cgroups.Cgroup); ok {
if err := s.ep.Add(container.ID, cg); err != nil {
logrus.WithError(err).Error("add cg to OOM monitor")
}
} else {
logrus.WithError(errdefs.ErrNotImplemented).Error("add cg to OOM monitor")
}
s.send(&eventstypes.TaskStart{
ContainerID: container.ID,
Pid: uint32(p.Pid()),
Expand Down
37 changes: 19 additions & 18 deletions runtime/v2/runc/v2/service.go
Expand Up @@ -330,27 +330,28 @@ func (s *service) Start(ctx context.Context, r *taskAPI.StartRequest) (*taskAPI.
s.eventSendMu.Unlock()
return nil, errdefs.ToGRPC(err)
}
switch cg := container.Cgroup().(type) {
case cgroups.Cgroup:
if err := s.ep.Add(container.ID, cg); err != nil {
logrus.WithError(err).Error("add cg to OOM monitor")
}
case *cgroupsv2.Manager:
allControllers, err := cg.RootControllers()
if err != nil {
logrus.WithError(err).Error("failed to get root controllers")
} else {
if err := cg.ToggleControllers(allControllers, cgroupsv2.Enable); err != nil {
logrus.WithError(err).Errorf("failed to enable controllers (%v)", allControllers)
}
}

// OOM monitor is not implemented yet
logrus.WithError(errdefs.ErrNotImplemented).Warn("add cg to OOM monitor")
}

switch r.ExecID {
case "":
switch cg := container.Cgroup().(type) {
case cgroups.Cgroup:
if err := s.ep.Add(container.ID, cg); err != nil {
logrus.WithError(err).Error("add cg to OOM monitor")
}
case *cgroupsv2.Manager:
allControllers, err := cg.RootControllers()
if err != nil {
logrus.WithError(err).Error("failed to get root controllers")
} else {
if err := cg.ToggleControllers(allControllers, cgroupsv2.Enable); err != nil {
logrus.WithError(err).Errorf("failed to enable controllers (%v)", allControllers)
}
}

// OOM monitor is not implemented yet
logrus.WithError(errdefs.ErrNotImplemented).Warn("add cg to OOM monitor")
}

s.send(&eventstypes.TaskStart{
ContainerID: container.ID,
Pid: uint32(p.Pid()),
Expand Down

0 comments on commit c55bd87

Please sign in to comment.