-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add space trimming check in ValidateSysctls #11224
Conversation
Cloud you consider adding something like this for ulimit? |
} | ||
_, err := ValidateSysctls(strSlice) | ||
assert.Error(t, err) | ||
} |
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.
Might be good to add a test that should pass, perhaps:
strSlice := []string{
" net.ipv4.ping_group_range=0 0 ",
" net.ipv4.ping_group_range=0 0 ",
}
Also, can you add a check for the error text you're expecting, or at least "extra spaces found" as the substring?
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.
@TomSweeneyRedHat thanks for suggestions. I was thinking that other tests for ValidateSysctls
would still go through my changes, as long as we don't see regressions on the other existing tests I think there's no need to introduce other test cases? I can still add a few if you wish.
Yes, I'll update my PR to check the message as well.
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.
Also, this won't be (and shouldn't be, IMO) passing, as we do arr := strings.Split(val, "=")
in ValidateSysctls
.
strSliceGood := []string{
" net.ipv4.ping_group_range=0 0 ",
" net.ipv4.ping_group_range=0 0 ",
}
_, err := ValidateSysctls(strSliceGood)
assert.Nil(t, err)
@unknowndevQwQ, I didn't look into that code path too closely, sorry.
Update: Just checked briefly on ulimits. It appears to be we are leveraging docker/go-units [1] in containers/common [1] https://github.com/docker/go-units/blob/master/ulimit.go#L66 |
This is to catch invalid sysctl configs with extra spacing. See containers/common#723 (comment) Signed-off-by: xatier <[email protected]>
@TomSweeneyRedHat @rhatdan, also once this is merged, I'll create another PR with the same change in https://github.com/containers/common/blob/main/pkg/sysclt/sysctl.go#L30 |
LGTM |
It would be nice if there was some way to allow spaces on both sides of the equal sign |
@unknowndevQwQ, I believe it makes more sense to stay with more restricted formats (i.e., no space). I am aware In [1] https://github.com/containers/common/blob/main/pkg/config/config.go#L90 |
/approve I am fine with either format, this is not going to be a common mistake. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: rhatdan, xatier The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/lgtm |
Sync with containers/podman#11224 Signed-off-by: Yan-Ming Li <[email protected]>
Sync with containers/podman#11224 Signed-off-by: Yan-Ming Li <[email protected]>
This is to catch invalid sysctl configs with extra spacing.
See
containers/common#723 (comment)
Signed-off-by: xatier [email protected]