chore: use container memory if containerised for oom notifications (#17062)

Currently we query only the underlying host's memory usage for our
memory resource monitor. This PR changes that to check if the workspace
is in a container, and if so it queries the container's memory usage,
falling back to the host's memory usage if not.
This commit is contained in:
Danielle Maywood
2025-03-24 11:14:21 +00:00
committed by GitHub
parent 674f60fc5b
commit 765e7058e8
4 changed files with 156 additions and 8 deletions
+4
View File
@@ -16,6 +16,10 @@ const (
kubernetesDefaultServiceAccountToken = "/var/run/secrets/kubernetes.io/serviceaccount/token" //nolint:gosec
)
func (s *Statter) IsContainerized() (ok bool, err error) {
return IsContainerized(s.fs)
}
// IsContainerized returns whether the host is containerized.
// This is adapted from https://github.com/elastic/go-sysinfo/tree/main/providers/linux/container.go#L31
// with modifications to support Sysbox containers.