diff options
author | Chong Cai <chongc@google.com> | 2021-08-12 18:29:40 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-08-12 18:32:01 -0700 |
commit | ddcf884e9d396930095ab1fde51b14201e8cf718 (patch) | |
tree | 27ce1f55cca136924a2564b51ceabdbbeebcd0e5 /runsc/container/container.go | |
parent | 02370bbd315d7e7c2783d7001d014870cf1ef534 (diff) |
Add Usage controls
Add Usage controls and implement "usage/usagefd" commands.
PiperOrigin-RevId: 390507423
Diffstat (limited to 'runsc/container/container.go')
-rw-r--r-- | runsc/container/container.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/runsc/container/container.go b/runsc/container/container.go index d1f979eb2..381f57574 100644 --- a/runsc/container/container.go +++ b/runsc/container/container.go @@ -652,6 +652,24 @@ func (c *Container) Cat(files []string, out *os.File) error { return c.Sandbox.Cat(c.ID, files, out) } +// Usage displays memory used by the application. +func (c *Container) Usage(full bool) (control.MemoryUsage, error) { + log.Debugf("Usage in container, cid: %s, full: %v", c.ID, full) + return c.Sandbox.Usage(c.ID, full) +} + +// UsageFD shows application memory usage using two donated FDs. +func (c *Container) UsageFD() (*control.MemoryUsageRecord, error) { + log.Debugf("UsageFD in container, cid: %s", c.ID) + return c.Sandbox.UsageFD(c.ID) +} + +// Reduce requests that the sentry attempt to reduce its memory usage. +func (c *Container) Reduce(wait bool) error { + log.Debugf("Reduce in container, cid: %s", c.ID) + return c.Sandbox.Reduce(c.ID, wait) +} + // State returns the metadata of the container. func (c *Container) State() specs.State { return specs.State{ |