From 8deb9495515b97898514e8ffb8f002c8afe3bfa7 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Thu, 26 Apr 2018 08:52:55 +0200 Subject: treewide: rework uci apply workflow Switch to rpcd based uci apply/rollback workflow which helps to avoid soft- bricking devices by requiring an explicit confirmation call after config apply. When a user now clicks "Save & Apply", LuCI first issues a call to uci apply which commits and reloads configuration, then goes into a polling countdown mode where it repeatedly attempts to call uci confirm. If the committed configuration is sane, the confirm call will go through and cancel rpcd's pending rollback timer. If the configuration change leads to a loss of connectivity (e.g. due to bad firewall rules or similar), the rollback mechanism will kick in after the timeout and revert configuration files and pending changes to the pre-apply state. In order to cover such rare cases where a lost of connectivity is expected and desired, the user is offered an "unchecked" apply option after timing out, which allows committing and applying the changes anyway, without the extra safety checks. As a consequence of this change, the luci-reload mechanism is now completely unsused since rpcd uses ubus config reload signals to reload affected services, which means that only procd-enabled services will receive proper reload treatment with the new workflow. Signed-off-by: Jo-Philipp Wich --- .../luasrc/view/admin_uci/apply.htm | 23 ----------------- .../luasrc/view/admin_uci/changes.htm | 29 +++++++++++----------- .../luasrc/view/admin_uci/revert.htm | 25 ++++++++++++++----- 3 files changed, 34 insertions(+), 43 deletions(-) delete mode 100644 modules/luci-mod-admin-full/luasrc/view/admin_uci/apply.htm (limited to 'modules/luci-mod-admin-full/luasrc/view/admin_uci') diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/apply.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/apply.htm deleted file mode 100644 index 370027e510..0000000000 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/apply.htm +++ /dev/null @@ -1,23 +0,0 @@ -<%# - Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich - Licensed to the public under the Apache License 2.0. --%> - -<%+header%> - -

<%:Configuration%> / <%:Apply%>

- -<% if changes then %> - <%+cbi/apply_xhr%> - <%+admin_uci/changelog%> - - <%- cbi_apply_xhr('uci-apply', configs) -%> - -

<%:The following changes have been committed%>:

- <%- uci_changelog(changes) -%> -<% else %> -

<%:There are no pending changes to apply!%>

-<% end %> - -<%+footer%> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm index 6e725c8888..9e9ce2be2a 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_uci/changes.htm @@ -1,40 +1,41 @@ <%# Copyright 2008 Steven Barth - Copyright 2008-2015 Jo-Philipp Wich + Copyright 2008-2018 Jo-Philipp Wich Licensed to the public under the Apache License 2.0. -%> <%+header%> +<%- + local node, redir_url = luci.dispatcher.lookup(luci.http.formvalue("redir")) + + include("cbi/apply_widget") + include("admin_uci/changelog") + + cbi_apply_widget(redir_url or url("admin/uci/changes")) +-%> +

<%:Configuration%> / <%:Changes%>

<% if changes then %> - <%+admin_uci/changelog%> <%- uci_changelog(changes) -%> <% else %>

<%:There are no pending changes!%>

<% end %> + +
- <% local node, url = luci.dispatcher.lookup(luci.http.formvalue("redir")); if url then %> + <% if redir_url then %>
-
+
<% end %>
-
- - " /> - -
-
- - " /> - -
+
" /> diff --git a/modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm b/modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm index 20327adff3..dff53420aa 100644 --- a/modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm +++ b/modules/luci-mod-admin-full/luasrc/view/admin_uci/revert.htm @@ -1,26 +1,39 @@ <%# Copyright 2008 Steven Barth - Copyright 2008 Jo-Philipp Wich + Copyright 2008-2018 Jo-Philipp Wich Licensed to the public under the Apache License 2.0. -%> <%+header%> +<%- + local node, redir_url = luci.dispatcher.lookup(luci.http.formvalue("redir")) + + include("cbi/apply_widget") + include("admin_uci/changelog") + + cbi_apply_widget(redir_url or url("admin/uci/revert")) +-%> +

<%:Configuration%> / <%:Revert%>

<% if changes then %> - <%+cbi/apply_xhr%> - <%+admin_uci/changelog%> -

<%:The following changes have been reverted%>:

<%- uci_changelog(changes) -%> <% else %>

<%:There are no pending changes to revert!%>

<% end %> -<% local node, url = luci.dispatcher.lookup(luci.http.formvalue("redir")); if url then %> + + + +<% if redir_url then %>
- +
-- cgit v1.2.3