-
Notifications
You must be signed in to change notification settings - Fork 25
fs2: ignore no device error when reading freezer state #25
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
Conversation
|
cc @kolyshkin |
kolyshkin
left a comment
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.
why not put ignore... into the same file, fs2/freezer.go? It is only used from 1 place.
Just a thought for the future — I saw a similar logic in runc. Maybe we should move it to cgroups, as it could be useful later on. For example: |
It is basically a one-liner and I'm not against reimplementing it a few times (rather than exposing as a public API). When we expose something as a public API, people start depending on it, and then we change the logic (in this case that would be adding another errno, or removing one) people will complain that we break backward compatibility. So, as much as I'm in for code reuse,
|
We can safely ignore the error in the following two common situations: 1. The cgroup path does not exist at the time of opening(eg: the kernel is too old) — indicated by os.IsNotExist. 2. The cgroup path is deleted during the seek/read operation — indicated by errors.Is(err, unix.ENODEV). These conditions are expected and do not require special handling. Unfortunately, the second case was accidentally removed during a code refactoring. We should add it back to ensure correct error handling. Signed-off-by: lifubang <[email protected]>
190c1ac to
6df7bae
Compare
Make sense, removed it now. |
kolyshkin
left a comment
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.
LGTM, thanks!
thaJeztah
left a comment
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.
LGTM
| // 2. The cgroup path is deleted during the seek/read operation — indicated by | ||
| // errors.Is(err, unix.ENODEV). | ||
| // These conditions are expected and do not require special handling. | ||
| if os.IsNotExist(err) || errors.Is(err, unix.ENODEV) { |
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.
Do you think we need to call out that we're deliberately using os.IsNotExist() here, instead of errors.Is (https://pkg.go.dev/os#IsNotExist) to prevent someone from updating the code, or would we be paying attention if that would happen?
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.
Let's address this as a followup.
When reading freezer state, we can safely ignore the error in the following two common situations:
Unfortunately, the second case was accidentally removed during a code refactoring. We should add it back to ensure correct error handling.
Fix: opencontainers/runc#4798