The changes leading to commit 077ef4f broke rebooting via
tools/swupdate-progress.c. Hence, adapt the C Lua bridge
lua_notify_progress() and update its invocation in
suricatta/server_wfx.lua as well as updating / fixing
Lua annotations.
Signed-off-by: Christian Storm <
christi...@siemens.com>
---
corelib/lua_interface.c | 17 +++++++++--------
doc/source/suricatta.rst | 8 ++++----
handlers/swupdate.lua | 5 +++--
suricatta/server_wfx.lua | 6 ++++--
suricatta/suricatta.lua | 5 +++--
5 files changed, 23 insertions(+), 18 deletions(-)
diff --git a/corelib/lua_interface.c b/corelib/lua_interface.c
index 8d57aaa9..1ff3e5e4 100644
--- a/corelib/lua_interface.c
+++ b/corelib/lua_interface.c
@@ -1232,17 +1232,18 @@ static int l_stat(lua_State *L)
* @brief Dispatch a message to the progress interface.
*
* @param [Lua] Message to dispatch to progress interface.
+ * @param [Lua] progress_cause_t number (optional), default: CAUSE_NONE
* @return [Lua] nil.
*/
int lua_notify_progress(lua_State *L) {
- /*
- * NOTE: level is INFOLEVEL for the sake of specifying a level.
- * It is unused in core/notifier.c :: progress_notifier() as the
- * progress emitter doesn't know about log levels.
- */
- notify(PROGRESS, RECOVERY_NO_ERROR, INFOLEVEL, luaL_checkstring(L, -1));
- lua_pop(L, 1);
- return 0;
+ lua_Number cause = CAUSE_NONE;
+ if (lua_isnumber(L, -1) == 1) {
+ cause = lua_tonumber(L, -1);
+ lua_pop(L, 1);
+ }
+ notify(PROGRESS, (progress_cause_t)cause, INFOLEVEL, luaL_checkstring(L, -1));
+ lua_pop(L, 1);
+ return 0;
}
/**
diff --git a/doc/source/suricatta.rst b/doc/source/suricatta.rst
index 474d02cc..a4081a63 100644
--- a/doc/source/suricatta.rst
+++ b/doc/source/suricatta.rst
@@ -557,10 +557,10 @@ The ``suricatta.status`` table exposes the ``server_op_res_t`` enum values defin
The ``suricatta.notify`` table provides the usual logging functions to the Lua
suricatta module matching their uppercase-named pendants available in the C realm.
-One notable exception is ``suricatta.notify.progress(message)`` which dispatches the
-message to the progress interface (see :doc:`progress`). Custom progress client
-implementations listening and acting on custom progress messages can be realized
-using this function.
+One notable exception is ``suricatta.notify.progress(message, cause)`` which
+dispatches the message to the progress interface (see :doc:`progress`). Custom
+progress client implementations listening and acting on custom progress messages
+can be realized using this function.
All notify functions return ``nil``.
diff --git a/handlers/swupdate.lua b/handlers/swupdate.lua
index aa8a31d0..d32f83b9 100644
--- a/handlers/swupdate.lua
+++ b/handlers/swupdate.lua
@@ -63,8 +63,9 @@ swupdate.warn = function(format, ...) end
swupdate.debug = function(format, ...) end
--- Lua equivalent of `notify(PROGRESS, ..., msg)`.
---- @param msg string Message to send to progress interface
-swupdate.progress = function(msg) end
+--- @param msg string Message to send to progress interface
+--- @param cause number | nil `progress_cause_t` value as defined in `include/progress_ipc.h`
+swupdate.progress = function(msg, cause) end
--- Lua equivalent of `notify(status, error, INFOLEVEL, msg)`.
--- @param status swupdate.RECOVERY_STATUS Current status, one of `swupdate.RECOVERY_STATUS`'s values
diff --git a/suricatta/server_wfx.lua b/suricatta/server_wfx.lua
index 0978ed50..d0b01bad 100644
--- a/suricatta/server_wfx.lua
+++ b/suricatta/server_wfx.lua
@@ -1471,8 +1471,10 @@ M.job.workflow.dispatch:set(
suricatta.notify.warn("Cannot initialize progress reporting channel, won't send progress.")
end
- suricatta.notify.progress(M.utils.string.escape([[{"%s": { "reboot-mode" : "no-reboot"}}]])
- :format(suricatta.ipc.progress_cause.CAUSE_REBOOT_MODE))
+ suricatta.notify.progress(
+ M.utils.string.escape([[{ "reboot-mode" : "no-reboot"}]]),
+ suricatta.ipc.progress_cause.CAUSE_REBOOT_MODE
+ )
suricatta.notify.debug(
"%s Version '%s' (Type: %s).",
diff --git a/suricatta/suricatta.lua b/suricatta/suricatta.lua
index 24d6eb8f..b8707a25 100644
--- a/suricatta/suricatta.lua
+++ b/suricatta/suricatta.lua
@@ -47,6 +47,7 @@ suricatta.status = {
--
-- Translates to `notify(string.format(message, ...))`,
-- @see `corelib/lua_interface.c`
+-- except for `suricatta.notify.progress()`.
--
--- @class suricatta.notify
suricatta.notify = {
@@ -60,8 +61,8 @@ suricatta.notify = {
info = function(message, ...) end,
--- @type fun(message: string, ...: any)
warn = function(message, ...) end,
- --- @type fun(message: string, ...: any)
- progress = function(message, ...) end,
+ --- @type fun(message: string, cause:suricatta.ipc.progress_cause?)
+ progress = function(message, cause) end,
}
--
2.50.1