Add config.defaults.version compatibility option#139
Add config.defaults.version compatibility option#139rgerhards wants to merge 1 commit intoratelimit-refactorfrom
Conversation
Summary of ChangesHello @rgerhards, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a new configuration mechanism to manage the compatibility of rsyslog's built-in defaults. By adding a Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
📖 Documentation Preview Ready!✅ Sphinx docs built and deployed for this PR. 🌐 Browse Online (Recommended):🔗 Quick Links:
🤖 This comment was generated by the docs workflow. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a config.defaults.version compatibility option, which is a great step towards modernizing defaults while maintaining backward compatibility. The implementation is solid, with good validation of the new configuration value. The documentation is also clear and helpful. My only suggestion is to refactor a piece of validation logic to improve its readability and maintainability.
| const long ver = strtol(value, &endptr, 10); | ||
| if (endptr != value + 4 || endptr == value || *endptr != '\0') { | ||
| parser_errmsg( | ||
| "config.defaults.version must be a 4-digit YYMM value; invalid value '%s' ignored (keeping %02u%02u)", | ||
| value, prevYear, prevMonth); | ||
| return; | ||
| } |
There was a problem hiding this comment.
The validation logic to ensure the value is a 4-digit string is functionally correct, but it's a bit complex and hard to understand at a glance. The condition endptr != value + 4 is a clever but obscure way to check for string length.
Refactoring this into a more straightforward check would improve code readability and maintainability. A clearer approach would be to first check the string length and then verify that it contains only digits.
const long ver = strtol(value, &endptr, 10);
if (strlen(value) != 4 || *endptr != '\0') {
parser_errmsg(
"config.defaults.version must be a 4-digit YYMM value; invalid value '%s' ignored (keeping %02u%02u)",
value, prevYear, prevMonth);
return;
}This prepares rsyslog to expose "versioned defaults" for new installs while keeping full backward compatibility for existing deployments. It adds a global knob that is parsed and stored now; later releases will consume it to switch baseline behavior. Impact: No default behavior change. New knob is validated; misconfig yields a config error and the previous baseline is retained. Before: no way to declare a defaults baseline in config. After: global 'config.defaults.version' (YYMM) is accepted, validated, and stored; defaults remain pinned to 0302 (Feb 2003) for now. Technical: - Introduce global "config.defaults.version" (eCmdHdlrGetWord). - Parse YYMM with bounds on month; on invalid input emit an error and keep the last accepted baseline in messages. - Add rsconf defaults: combined YYMM, year, month, and "explicit" flag. - Initialize/reset these in `cnfSetDefaults()` and `resetConfigVariables()` using new macros pinned to 0302 to preserve historic behavior. - Wire application in `glblDoneLoadCnf()` via configDefaultsVersionApply(). - Document the knob in rainerscript globals (available 8.2508.0+), with default noted as February 2003 compatibility baseline. Non-technical: This provides plumbing so new deployments can opt into modern defaults, while existing systems can lock to legacy behavior. It improves maintainability and a future path to safer, modern defaults without surprising upgrades. With the help of AI Agents: ChatGPT codex
f314c9d to
6c00387
Compare
Summary
config.defaults.versionglobal option that records the release baseline for built-in defaultsglobal()referenceTesting
https://chatgpt.com/codex/tasks/task_e_68e125b1ca588332860ee1898f18c1eb