Add umask option to system config with validation and worker support #5121
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.
Title:
feat(system): add umask option to system config with validation and documentation
Summary
This PR adds support for a umask option in the configuration block of Fluentd.
Previously, users could only set umask via the command-line flag --umask, which was inconvenient for services and containerized deployments.
Example usage in fluent.conf:
umask 0022Motivation
Allow users to set default file permission masks without using CLI flags.
Ensure multi-worker mode also respects the configured umask.
Improve usability for production deployments and containerized environments.
Changes
Added config_param :umask, :string, default: nil to SystemConfig.
Implemented apply_umask method:
Parses octal values (0022, 0077, etc.)
Validates range (000–777)
Logs applied umask or warnings for invalid values
Sets process umask early during startup, before worker spawn
Updated tests to cover:
Valid umask
Invalid values
Out-of-range values
Added documentation in docs/configuration/system.md.
Bug Fixes / Improvements
Fixes issue where umask previously only worked in standalone mode.
Adds logging for visibility of applied umask.
Gracefully handles invalid input without crashing Fluentd.
Ensures umask affects all files created by Fluentd (logs, buffer, pos files).
Testing
Manual test:
Add umask 0077 in fluent.conf.
Start Fluentd: bin/fluentd -c fluent.conf.
Observe logs: System umask changed from … to 0077.
Verify file creation permissions reflect the umask.
Unit tests added to test/config/test_system_config.rb:
Valid umask
Invalid string umask
Out-of-range umask