fix: fail to inject StressChaos in certain cgroup v1 environment because PidPath
returns an unexpected error
#4407
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.
What problem does this PR solve?
Close #4406
This PR fixes the issue that in some certain cgroup v1 environments, Chaos Mesh fails to inject StressChaos to the Pod. A typical error message would like:
The problem is the chaos-daemon fails to handle when cgroup controller presents in
/sys/fs/cgroup
but is not enabled for the target pod. For my case:From code, the error
controller is not supported
is returned byPidPath
when runningcgroups.Load
. Actually,cgroups.Load
could handle this situation, as if thepath
function (which isPidPath
here) returnsErrControllerNotActive
error.https://github.com/containerd/cgroups/blob/fa6f6841ed3d57355acadbc06f1d7ed4d91ac4f7/cgroup1/cgroup.go#L93
But now
PidPath
returns an unexpected errorerrors.New("controller is not supported")
instead.chaos-mesh/pkg/chaosdaemon/cgroups/pidpath.go
Lines 56 to 61 in 38e49da
What's changed and how it works?
This PR changes the returned error to
ErrControllerNotActive
. This behaves the same as the implementation in containerd/cgroup.https://github.com/containerd/cgroups/blob/4dacf2bc1300b0d7dc1087b8e27712a597890ba3/paths.go#L80-L85
Related changes
UI interface
Cherry-pick to release branches (optional)
Checklist
CHANGELOG
CHANGELOG.md
Tests
Side effects
DCO
If you find the DCO check fails, please run commands like below (Depends on the actual situations. For example, if the failed commit isn't the most recent) to fix it: