2016-07-10 06:01:14 +00:00
|
|
|
package executor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"sync"
|
|
|
|
|
|
|
|
cgroupConfig "github.com/opencontainers/runc/libcontainer/configs"
|
|
|
|
)
|
|
|
|
|
2016-07-11 07:02:55 +00:00
|
|
|
// resourceContainerContext is a platform-specific struct for managing a
|
|
|
|
// resource container. In the case of Linux, this is used to control Cgroups.
|
|
|
|
type resourceContainerContext struct {
|
2018-09-24 18:37:45 +00:00
|
|
|
groups *cgroupConfig.Cgroup
|
|
|
|
cgLock sync.Mutex
|
2016-07-10 06:45:33 +00:00
|
|
|
}
|
|
|
|
|
2016-07-10 06:25:33 +00:00
|
|
|
// cleanup removes this host's Cgroup from within an Executor's context
|
2016-07-11 07:02:55 +00:00
|
|
|
func (rc *resourceContainerContext) executorCleanup() error {
|
2016-07-10 06:01:14 +00:00
|
|
|
rc.cgLock.Lock()
|
|
|
|
defer rc.cgLock.Unlock()
|
2018-09-24 18:37:45 +00:00
|
|
|
if err := DestroyCgroup(rc.groups, os.Getpid()); err != nil {
|
2016-07-10 06:01:14 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|