Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 24, 2025

Conversation

DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Mar 23, 2025

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.

A container may not have a memory limit set. If there is no memory limit
set, we want to fallback to using the memory available on the underlying
host.
} else {
mem, err = f.HostMemory(clistat.PrefixDefault)
if err != nil {
return 0, 0, xerrors.Errorf("failed to host fetch memory: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0, 0, xerrors.Errorf("failed to host fetch memory: %w", err)
return 0, 0, xerrors.Errorf("failed to fetch host memory: %w", err)

if mem.Total == nil {
hostMem, err := f.HostMemory(clistat.PrefixDefault)
if err != nil {
return 0, 0, xerrors.Errorf("failed to host fetch memory: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return 0, 0, xerrors.Errorf("failed to host fetch memory: %w", err)
return 0, 0, xerrors.Errorf("failed to fetch host memory: %w", err)

@DanielleMaywood DanielleMaywood marked this pull request as ready for review March 24, 2025 10:36
@DanielleMaywood DanielleMaywood merged commit 765e705 into main Mar 24, 2025
32 checks passed
@DanielleMaywood DanielleMaywood deleted the dm-use-container-memory branch March 24, 2025 11:14
@github-actions github-actions bot locked and limited conversation to collaborators Mar 24, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants