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

View File

@ -965,7 +965,10 @@ func (a *agent) run() (retErr error) {
if err != nil {
return xerrors.Errorf("failed to create resources fetcher: %w", err)
}
resourcesFetcher := resourcesmonitor.NewFetcher(statfetcher)
resourcesFetcher, err := resourcesmonitor.NewFetcher(statfetcher)
if err != nil {
return xerrors.Errorf("new resource fetcher: %w", err)
}
resourcesmonitor := resourcesmonitor.NewResourcesMonitor(logger, clk, config, resourcesFetcher, aAPI)
return resourcesmonitor.Start(ctx)