Conversation
openwrt-ai
left a comment
There was a problem hiding this comment.
Commit checks
- 3825bbc "luci-app-keepalived: don't write alt_config_file unless requested" — the stated root cause ("
.defaultis submitted as the field's value whenever it renders with no existing UCI value") contradictsform.js:2152, which removes anoptionaloption whose form value equals.default. Please re-check the mechanism and rewrite the rationale against what the code actually does, or name the LuCI revision where the write happens.
Generated by Claude Code
| o.optional = true; | ||
| o.default = '/etc/keepalived/keepalived.conf'; |
There was a problem hiding this comment.
With optional = true, a form value equal to .default is never written: form.js:2152 takes the remove() branch when formvalue() == this.default. That makes /etc/keepalived/keepalived.conf the one path a user can never actually select and persist, and dropping the default is the smaller fix for the unwanted write too.
| o.optional = true; | |
| o.default = '/etc/keepalived/keepalived.conf'; | |
| o.optional = true; |
Generated by Claude Code
| o.optional = true; | ||
| o.placeholder = 'OpenWrt'; | ||
|
|
||
| o = s.option(form.Flag, 'use_alt_config_file', _('Use alternative config file'), |
There was a problem hiding this comment.
This gets persisted as option use_alt_config_file '1' in /etc/config/keepalived, but no consumer reads it — the name appears nowhere in keepalived.init. Is a UI-only marker in the config file intended, rather than deriving the state from alt_config_file alone as cfgvalue() below already does?
Generated by Claude Code
| o.default = o.disabled; | ||
| o.rmempty = true; | ||
| o.cfgvalue = function(section_id) { | ||
| var v = form.Flag.prototype.cfgvalue.apply(this, [section_id]); |
There was a problem hiding this comment.
nit: var — this file and current luci JS use let/const. Same on line 31.
| var v = form.Flag.prototype.cfgvalue.apply(this, [section_id]); | |
| const v = form.Flag.prototype.cfgvalue.apply(this, [section_id]); |
Generated by Claude Code
| } | ||
| return v; | ||
| }; | ||
|
|
There was a problem hiding this comment.
The "Alternative config" FileUpload field set:
o.default = '/etc/keepalived/keepalived.conf';
For form.Value-derived widgets, .default is submitted as the
field's value whenever it renders with no existing UCI value --
it is not merely a placeholder. As a result, saving the Global
Settings page for the first time, without the user ever
touching this field, silently wrote
globals.alt_config_file into /etc/config/keepalived.
Once that option is set, keepalived.init's process_config()
symlinks the runtime config straight to that file and skips
generating it from the rest of the UCI sections (vrrp_instance,
ipaddress, track_interface, peer, ...) entirely, so every other
setting configured through LuCI is silently ignored and the
daemon runs whatever native config happens to be at that path.
Add an explicit "Use alternative config file" flag, defaulting
to off, and only show/write alt_config_file when it is enabled.
For upgrades where alt_config_file is already present from a
prior save, default the new flag to on so existing,
intentionally-configured setups are preserved rather than
silently cleared.
Signed-off-by: Jackie Han <jackie.han@gmail.com>
3825bbc to
10b0d4e
Compare
The "Alternative config" FileUpload field set:
For form.Value-derived widgets, .default is submitted as the field's value whenever it renders with no existing UCI value -- it is not merely a placeholder. As a result, saving the Global Settings page for the first time, without the user ever touching this field, silently wrote
globals.alt_config_file into /etc/config/keepalived.
Once that option is set, keepalived.init's process_config() symlinks the runtime config straight to that file and skips generating it from the rest of the UCI sections (vrrp_instance, ipaddress, track_interface, peer, ...) entirely, so every other setting configured through LuCI is silently ignored and the daemon runs whatever native config happens to be at that path.
Add an explicit "Use alternative config file" flag, defaulting to off, and only show/write alt_config_file when it is enabled. For upgrades where alt_config_file is already present from a prior save, default the new flag to on so existing, intentionally-configured setups are preserved rather than silently cleared.
Tested on
OpenWrt version: 25.12.5 r33051-f5dae5ece4
LuCI version: 26.263.44884~0834d09
Web browser(s): Safari 27.0 (22625.1.29.11.27)
Before
After
Signed-off-by: Jackie Han jackie.han@gmail.com