Skip to content
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

Support Service Limits specified in Bytes #268

Merged
merged 1 commit into from
Mar 28, 2022

Conversation

optiz0r
Copy link
Contributor

@optiz0r optiz0r commented Mar 24, 2022

Pull Request (PR) description

Previously the ServiceLimits type restricted limits specified in bytes to contain
a multiplicative suffix. The systemd man pages ([0], [1]) specify these are optional
and a bare integer can be specified, which will be interpreted as Bytes.

This commit makes the multiplicative suffixes optional, and adds tests for two cases
to ensure non-suffixed values are accepted.

[0] https://www.freedesktop.org/software/systemd/man/systemd.exec.html
(For Limit* options)
[1] https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#
(For Memory* options)

Previously the ServiteLimits type restricted limits specified in bytes to contain
a multiplicative suffix. The systemd man pages ([0], [1]) specify these are optional
and a bare integer can be specified, which will be interpreted as Bytes.

This commit makes the multiplicative suffixes optional, and adds tests for two cases
to ensure non-suffixed values are accepted.

[0] https://www.freedesktop.org/software/systemd/man/systemd.exec.html
    (For `Limit*` options)
[1] https://www.freedesktop.org/software/systemd/man/systemd.resource-control.html#
    (For `Memory*` options)
@traylenator
Copy link
Contributor

I get that values without units is permissible but maybe it's a good thing to encourage by forcing units to be specified?

@optiz0r
Copy link
Contributor Author

optiz0r commented Mar 24, 2022

The use case we have for this is the same configuration needs to be done in multiple places, and one place (pam) does not support suffixed units, and we would like to be able to use the same hiera value to drive both. The current validation prevents this, despite it being legal config. The alternative is having to duplicate config, or having some puppet function that can translate between suffixed and non-suffixed values to work around this validation being overly strict.

That said, I've just re-checked the docs for both, and pam takes kilobytes, whereas systemd takes bytes, so taking the pam value as is and shoving a K on the end would achieve the same result as trying to specify the value as an integer number of bytes multiplied by 1024.

@traylenator
Copy link
Contributor

traylenator commented Mar 25, 2022

For that use case you can probably do.

pam::thing: 500
systems::thing: "%{alias(pam::thing)}b"

Or if it is in the same file with a YAML variable.

Copy link
Member

@smortex smortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the part about PAM, it seems to be something you care on your control repo and out of scope of this PR, so I will ignore it.

If we reject acceptable value we need to adjust our code and this look fire to me.

@bastelfreak bastelfreak added the enhancement New feature or request label Mar 28, 2022
@bastelfreak bastelfreak merged commit caf83c4 into voxpupuli:master Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants