allow sysctl assignments to fail#13191
Conversation
keszybz
left a comment
There was a problem hiding this comment.
This breaks compat with sysctl. I guess that's OK, there isn't much reason to run sysctl on a sysctl.d file that systemd ships. If Debian or others want to retain compat with both, they'll have to refrain from using "-" in any files that are installed on non-systemd systems.
| </para> | ||
|
|
||
| <para>If a variable assignment is prefixed with a single <literal>-</literal> character, any attempts to | ||
| set it that fail will be ignored (though are logged). Moreover, any access permission errors, and |
There was a problem hiding this comment.
Maybe:
Any access permission errors and attempts to write variables not defined on the local system are logged, but do not cause the the service to fail. Moreover, if a variable assignment is prefixed with a single "-" character, failure to set the variable will be logged, but will not cause the service to fail. All other errors when setting variables cause the service to return failure at the end (other variables are still processed).
| # That's not so bad because values between 2^31 and 2^32-1 are reserved on | ||
| # systemd-based systems anyway: https://systemd.io/UIDS-GIDS.html#summary | ||
| net.ipv4.ping_group_range = 0 2147483647 | ||
| -net.ipv4.ping_group_range = 0 2147483647 |
There was a problem hiding this comment.
This is not compatible with sysctl anymore, and will in particular break sysctl --system.
|
Given that originally this is mostly supposed to make ping work in "rootless containers" I'd wait for someone from that camp to chime in to find out whether they are on board with ignoring all the errors. (If I tried to push this I wouldn't be OK). Other than that, I'm not sure how extensible this format is. I generally can imagine an RFE about ignoring some errors in containers only for example. |
My motivation behind submitting #13141 was to get From that perspective, it seems enough to have On my host: Inside a Toolbox container: |
|
regarding the compat issue in the sysctl file format: note that upstream procps-ng still doesn't support /etc/sysctl.d/ iirc, it only reads /etc/sysctl.conf. So as long as that specific file doesn't do the "-" thing (and I don't think it should bother with that, as it's mostly the user's own configuration, all packages tend to use /usr/lib/sysctl.d/ drop-ins that, and the "-" is mostly something that is useful for keep things generically shippable in RPMs). Also, we could probably file an RFE bug in procps-ng upstream requesting they also consider adding support for that. |
|
I requested support for the "-" syntax here now: https://gitlab.com/procps-ng/procps/issues/138 Let's see how that goes. |
Got it. If we're talking about development environments where nobody is expected to debug why ping has stopped working at 3 am I think it's generally OK to let |
|
@poettering regarding the "-" syntax and my hypothetical RFE regarding ignoring some errors in containers only, in this particular case it would be kind helpful to do that. Are you planning to support something like "skip EINVAL for this thing in containers only"? |
|
OK, let's merge this and to the wording fixups separately. |
Hmm, I'd prefer not to ignore errors too aggressively, sometimes they might matter. Note that So I think we should be all good in this regard, by ignoring the error in containers: the host will whitelist this for us anyway, and we couldn't whitelist anyway what the host didn't whitelist for us. |
hmm, let's not get overboard with adding more and more conditons like this. I think our goal should be have everything as generic as possible and only do per-container exceptions where we really have to, and I think this case is not too strng... after all, if we fail to write the sysctl on the host for an unknown reason and then ignore the failure, it really shouldn't matter much: what will happen then is that ping() will fail with EPERM for some folks, which isn't particular bad, and a clearly recognizable error anway. i.e. we don't break stuff where it was too late, all we do when writing fails and we ignore it is shift the error elsewhere. |
I was kind of spitballing just to make sure that hypothetical extensibility (that hypothetically would make it easier to add some stuff without caring about containers) was covered and to figure out where this is going in general but to be honest I was hoping to hear something like this :-) |
My attempt to address #13177. Seems to work fine, and does the right thing with a long term fix.