-
Notifications
You must be signed in to change notification settings - Fork 60
Change settings.go to ignore user input for OOM killer if running under Cgroupv2 #151
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
Open
m3ow-dev
wants to merge
1
commit into
pelican-dev:main
Choose a base branch
from
m3ow-dev:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Improve error handling to distinguish file-not-found from other errors.
The current implementation treats any error from
os.Statas an indication of cgroup v1, which could lead to incorrect behavior if the error is due to permission issues, I/O errors, or other filesystem problems rather than the file not existing.Apply this diff to properly handle errors:
This approach:
os.IsNotExistto specifically check for file-not-found📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be the best way check if the file doesn't exist instead of any error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
💡 Result:
Best practice (Go 1.13+): prefer
errors.Is(err, fs.ErrNotExist).osdocs explicitly note thatos.IsNotExistpredateserrors.Isand say: “New code should useerrors.Is(err, fs.ErrNotExist).” [1]os.ErrNotExistis just an alias offs.ErrNotExist(ErrNotExist = fs.ErrNotExist). [2]Avoid direct comparison (
err == os.ErrNotExistorerr == fs.ErrNotExist) because filesystem calls typically return wrapped errors like*os.PathError(and may wrap syscall errors), so equality often won’t match even when the underlying condition is “does not exist”. Usingerrors.Is(oros.IsNotExist) handles that. [1][3]When is
os.IsNotExistOK? For older codebases or when you want the legacy helper; it still works, buterrors.Is(..., fs.ErrNotExist)is the modern, general approach. [1]Sources: [1] https://golang.bg/pkg/os/ (IsNotExist docs) · [2] https://golang.bg/src/os/error.go (ErrNotExist alias) · [3] https://stackoverflow.com/questions/33398110/in-golang-os-openfile-doesnt-return-os-errnotexist-if-file-does-not-exist
@parkervcp, I appreciate the feedback! However, direct comparison witherr == os.ErrNotExistunfortunately won't work reliably in this case. Here's why:os.Stat()returns wrapped errors (typically*os.PathError), not the rawos.ErrNotExist, so direct equality comparison will always befalseeven when the file doesn't exist.Modern best practice (Go 1.13+):
Also acceptable (legacy helper):
Both
errors.Is()andos.IsNotExist()properly unwrap the error to check the underlying condition, while direct comparison does not. The Go documentation foros.IsNotExistexplicitly recommends usingerrors.Is(err, fs.ErrNotExist)for new code.Would you prefer
errors.Is(err, fs.ErrNotExist)(modern approach) oros.IsNotExist(err)(simpler, still works)?