From 8843810954eccbf7976851a1931c06730fb4fb5b Mon Sep 17 00:00:00 2001 From: Christian Korber Date: Mon, 10 Feb 2025 09:15:19 +0100 Subject: [PATCH] luci-app-keepalived: include FAULT state to state Upstream only handles state according to whether the machine was in BACKUP or MASTER. FAULT state is not handled but upstream keepalived does support that by exporting json with `state` which reflects the state (FAULT included). Signed-off-by: Christian Korber --- .../resources/view/keepalived/overview.js | 16 +++++++++++++++- .../view/status/include/35_keepalived.js | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/applications/luci-app-keepalived/htdocs/luci-static/resources/view/keepalived/overview.js b/applications/luci-app-keepalived/htdocs/luci-static/resources/view/keepalived/overview.js index 943d9ac732..f241cc3d05 100644 --- a/applications/luci-app-keepalived/htdocs/luci-static/resources/view/keepalived/overview.js +++ b/applications/luci-app-keepalived/htdocs/luci-static/resources/view/keepalived/overview.js @@ -39,7 +39,21 @@ return view.extend({ cbi_update_table(table, targets.map(function(target) { - var state = (target.stats.become_master - target.stats.release_master) ? 'MASTER' : 'BACKUP'; + var state; + var instance_state = target.data.state; + + if (instance_state === 2) { + state = 'MASTER'; + } else if (instance_state === 1) { + state = 'BACKUP'; + } else if (instance_state === 0) { + state = 'INIT'; + } else if (instance_state === 3) { + state = 'FAULT'; + } else { + state = 'UNKNOWN'; + } + if (instances != '') { for (var i = 0; i < instances.length; i++) { if (instances[i]['name'] == target.data.iname) { diff --git a/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js b/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js index cf870ece92..f4b83e76d7 100644 --- a/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js +++ b/applications/luci-app-keepalived/htdocs/luci-static/resources/view/status/include/35_keepalived.js @@ -38,7 +38,21 @@ return baseclass.extend({ cbi_update_table(table, targets.map(function(target) { - var state = (target.stats.become_master - target.stats.release_master) ? 'MASTER' : 'BACKUP'; + var state; + var instance_state = target.data.state; + + if (instance_state === 2) { + state = 'MASTER'; + } else if (instance_state === 1) { + state = 'BACKUP'; + } else if (instance_state === 0) { + state = 'INIT'; + } else if (instance_state === 3) { + state = 'FAULT'; + } else { + state = 'UNKNOWN'; + } + if (instances != '') { for (var i = 0; i < instances.length; i++) { if (instances[i]['name'] == target.data.iname) { -- 2.30.2