Skip to content

luci-app-keepalived: default the enabled flag to match init script - #9062

Open
Jackie264 wants to merge 1 commit into
openwrt:masterfrom
Jackie264:fix-luci-app-keepalived
Open

Jackie264 wants to merge 1 commit into
openwrt:masterfrom
Jackie264:fix-luci-app-keepalived

Conversation

@Jackie264

@Jackie264 Jackie264 commented Sep 22, 2026

Copy link
Copy Markdown

The "Enabled" Flag on the globals page defaulted to o.disabled,
but files/keepalived.init treats a missing globals.enabled
option as enabled:

config_get_bool enabled globals enabled 1

CBIFlag.parse() removes an option from UCI whenever the
submitted value equals the widget's .default, and writes it
explicitly otherwise. With the default set to disabled, ticking
the box submitted '1', which did not match the default, so it
was written explicitly -- that direction worked. Unticking the
box submitted '0', which matched the default, so the option was
removed instead of being written, and with it gone the init
script fell back to its own enabled=1 default. Unticking
"Enabled" therefore never actually disabled the service.

Set the form default to o.enabled so the comparison lines up
with the init script instead of fighting it: ticking now
matches the default and removes the option (falling back to the
init script's own enabled=1), while unticking no longer matches
the default and explicitly writes enabled='0'.

Depends on / companion fix: openwrt/packages#30582

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)

Signed-off-by: Jackie Han jackie.han@gmail.com

@Jackie264

Copy link
Copy Markdown
Author

Please take the time to review it.
@stokito @jempatel

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Commit checks

  • 2891ccb "luci-app-keepalived: default the enabled flag to match init script" — the body inverts which direction was broken. CBIFlag.parse() removes the option only when the submitted value equals .default, so with default = o.disabled ticking submitted '1''0' and was written; it was unticking that submitted '0' == '0', got removed, and left the init script's enabled=1 fallback in force. Reword so the removed-on-submit case is the untick (and drop "since the field started out already at its default value" — the initial state is not what parse() compares). The same paragraph in the PR description needs the same correction.

Generated by Claude Code


o = s.option(form.Flag, 'enabled', _('Enabled'));
o.default = o.disabled;
o.default = o.enabled;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be better to make it o.default = true;
See #7140 (comment)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes, sir. It's done.

@openwrt openwrt Bot added the not following guidelines Pull request does not follow formatting guidelines label Sep 23, 2026
@Jackie264
Jackie264 force-pushed the fix-luci-app-keepalived branch from d411553 to 34a108b Compare September 23, 2026 23:14
The "Enabled" Flag on the globals page defaulted to o.disabled,
but files/keepalived.init treats a missing globals.enabled
option as enabled:

    config_get_bool enabled globals enabled 1

form.Flag omits an option from UCI whenever the submitted value
equals its .default. With the default set to disabled, ticking
the box (submitting '1') was treated as "back to default" and
the option was silently removed instead of being written, which
made the init script fall back to its own enabled=1 default
anyway. Unticking the box likewise never wrote '0', since the
field started out already at its (wrong) default value.

Net effect: the checkbox could tick and untick freely in the UI
but never actually changed whether the service would start,
because the option it controls was never written on either
side of the toggle in the direction that mattered.

Set the form default to o.enabled so it matches the init
script's assumption: ticking removes the option (falls back to
enabled=1), unticking explicitly writes enabled='0'.

Signed-off-by: Jackie Han <jackie.han@gmail.com>

Set default enabled flag to true in globals.js

Signed-off-by: Jackie Han <jackie.han@gmail.com>
@Jackie264
Jackie264 force-pushed the fix-luci-app-keepalived branch from 34a108b to 061d423 Compare September 23, 2026 23:47
@openwrt openwrt Bot removed the not following guidelines Pull request does not follow formatting guidelines label Sep 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants