The branch, master has been updated
via 56e6f810b01 ctdb-event: Replace "no data" event scripts with
previous data
via 52ab5fa8b2b ctdb-event: Don't replace an existing result with NULL
via a05a2be09d7 ctdb-common: Make run_event return full script list
via 20e9f203627 ctdb-common: Factor out new function run_event_fail()
from 6a1be2ff2af gpfs: Fetch GPFS DOS attributes asynchronously
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 56e6f810b019a5475c850007494ff5404c5472da
Author: Martin Schwenke <[email protected]>
Date: Mon Sep 29 17:24:53 2025 +1000
ctdb-event: Replace "no data" event scripts with previous data
If an event script list contains results with "no data" (summary ==
-ENODATA), then overwrite these with results from the previous run,
where possible.
To maintain current behaviour in "ctdb event status ...", stop
processing scripts if the begin timestamp in the list goes backwards.
This maintains backward compatibility, where only status for scripts
from the most recent run are shown.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
Autobuild-User(master): Ralph Böhme <[email protected]>
Autobuild-Date(master): Tue Oct 7 11:09:41 UTC 2025 on atb-devel-224
commit 52ab5fa8b2b3c0cf1e464d939f9930cb63b243e6
Author: Martin Schwenke <[email protected]>
Date: Fri Sep 26 15:58:26 2025 +1000
ctdb-event: Don't replace an existing result with NULL
If script_list is NULL then event->script_list is set to NULL by
TALLOC_FREE(). This seems like the wrong thing to do because NULL
indicates a problem running the current event. We should keep the
previous result because it contains useful information.
In theory, this can't happen because the caller checks for NULL.
However, given that the check is here, it might as well do the right
thing... and this simplifies a subsequent change.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit a05a2be09d71f49e06299dc79d36f5aa8dd8c212
Author: Martin Schwenke <[email protected]>
Date: Mon Sep 29 15:24:10 2025 +1000
ctdb-common: Make run_event return full script list
run_event currently truncates the resulting script list after the
first failure.
Instead, return the full script list, with scripts that weren't run
flagged with ENODATA in their summary. This structure is zeroed on
allocation, so this is the only field that needs to be set.
For now, have the event tool skip such scripts. Do this in
print_status() instead of print_status_one(), since there will soon be
additional checks in print_status() and it makes sense to put them
together.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
commit 20e9f203627752c4c1934e4bc0776e26c0dfb00e
Author: Martin Schwenke <[email protected]>
Date: Mon Sep 29 14:58:01 2025 +1000
ctdb-common: Factor out new function run_event_fail()
Mostly due to future indentation requirements.
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Ralph Boehme <[email protected]>
-----------------------------------------------------------------------
Summary of changes:
ctdb/common/run_event.c | 39 ++++++++++++++++++++--------
ctdb/event/event_context.c | 65 +++++++++++++++++++++++++++++++++++++++++++---
ctdb/event/event_tool.c | 24 ++++++++++++++++-
3 files changed, 113 insertions(+), 15 deletions(-)
Changeset truncated at 500 lines:
diff --git a/ctdb/common/run_event.c b/ctdb/common/run_event.c
index 30369eeff22..dee46ad2949 100644
--- a/ctdb/common/run_event.c
+++ b/ctdb/common/run_event.c
@@ -546,6 +546,9 @@ static void run_event_cancel(struct tevent_req *req);
static void run_event_trigger(struct tevent_req *req, void *private_data);
static struct tevent_req *run_event_run_script(struct tevent_req *req);
static void run_event_next_script(struct tevent_req *subreq);
+static void run_event_fail(struct tevent_req *req,
+ struct run_event_script *script,
+ id_t pid);
static void run_event_debug(struct tevent_req *req, pid_t pid);
static void run_event_debug_done(struct tevent_req *subreq);
@@ -763,17 +766,7 @@ static void run_event_next_script(struct tevent_req
*subreq)
state->script_list->summary = script->summary;
if (! state->continue_on_failure) {
- state->script_list->num_scripts = state->index + 1;
-
- if (script->summary == -ETIMEDOUT && pid != -1) {
- run_event_debug(req, pid);
- }
- D_NOTICE("%s event %s\n", state->event_str,
- (script->summary == -ETIMEDOUT) ?
- "timed out" :
- "failed");
- run_event_stop_running(state->run_ctx);
- tevent_req_done(req);
+ run_event_fail(req, script, pid);
return;
}
}
@@ -796,6 +789,30 @@ static void run_event_next_script(struct tevent_req
*subreq)
state->script_subreq = subreq;
}
+static void run_event_fail(struct tevent_req *req,
+ struct run_event_script *script,
+ id_t pid)
+{
+ struct run_event_state *state = tevent_req_data(
+ req, struct run_event_state);
+ struct run_event_script_list *script_list = state->script_list;
+ unsigned int i;
+
+ /* Mark remaining scripts as having no data */
+ for (i = state->index + 1; i < script_list->num_scripts; i++) {
+ script_list->script[i].summary = -ENODATA;
+ }
+
+ if (script->summary == -ETIMEDOUT && pid != -1) {
+ run_event_debug(req, pid);
+ }
+ D_NOTICE("%s event %s\n",
+ state->event_str,
+ (script->summary == -ETIMEDOUT) ? "timed out" : "failed");
+ run_event_stop_running(state->run_ctx);
+ tevent_req_done(req);
+}
+
static void run_event_debug(struct tevent_req *req, pid_t pid)
{
struct run_event_state *state = tevent_req_data(
diff --git a/ctdb/event/event_context.c b/ctdb/event/event_context.c
index 79bcd834576..afde9b0542e 100644
--- a/ctdb/event/event_context.c
+++ b/ctdb/event/event_context.c
@@ -134,6 +134,9 @@ static int eventd_event_set(struct event_component *comp,
struct run_event_script_list *script_list)
{
struct event_event *event = NULL;
+ struct run_event_script_list *old_list = NULL;
+ unsigned int n = 0;
+ unsigned int o = 0;
int ret;
ret = eventd_event_add(comp, event_name, &event);
@@ -141,11 +144,67 @@ static int eventd_event_set(struct event_component *comp,
return ret;
}
- TALLOC_FREE(event->script_list);
- if (script_list != NULL) {
- event->script_list = talloc_steal(event, script_list);
+ /* Don't replace previous result with a failed one */
+ if (script_list == NULL) {
+ return 0;
+ }
+
+ old_list = event->script_list;
+ event->script_list = talloc_steal(event, script_list);
+
+ /* No previous run, so the loop below can't be run */
+ if (old_list == NULL) {
+ goto done;
+ }
+
+ /* The loop below is a no-op if no script failed, so optimise */
+ if (script_list->summary == 0) {
+ goto done;
+ }
+
+ /*
+ * Replace any "no data" items in the new list with the data
+ * from the old list
+ */
+ while (n < script_list->num_scripts && o < old_list->num_scripts) {
+ struct run_event_script *new = &script_list->script[n];
+ struct run_event_script *old = &old_list->script[o];
+
+ /*
+ * If these are the same event, copy data if "no
+ * data". Otherwise step through the lists.
+ */
+ ret = strcmp(new->name, old->name);
+ if (ret < 0) {
+ n++;
+ continue;
+ }
+ if (ret > 0) {
+ o++;
+ continue;
+ }
+
+ if (new->summary == -ENODATA) {
+ /*
+ * Do not do a struct assignment here. This
+ * would cause name and output to point to
+ * memory allocated off old_list, and that is
+ * freed below.
+ */
+ new->begin = old->begin;
+ new->end = old->end;
+ new->result = old->result;
+ new->summary = old->summary;
+ new->output = talloc_move(event->script_list,
+ &old->output);
+ }
+
+ n++;
+ o++;
}
+done:
+ TALLOC_FREE(old_list);
return 0;
}
diff --git a/ctdb/event/event_tool.c b/ctdb/event/event_tool.c
index d6b7156c69b..baf4763cb1f 100644
--- a/ctdb/event/event_tool.c
+++ b/ctdb/event/event_tool.c
@@ -262,6 +262,7 @@ static void print_status(const char *component,
int result,
struct ctdb_event_reply_status *status)
{
+ struct timeval prev = { .tv_sec = 0, };
int i;
if (result != 0) {
@@ -281,7 +282,28 @@ static void print_status(const char *component,
}
for (i=0; i<status->script_list->num_scripts; i++) {
- print_status_one(&status->script_list->script[i]);
+ struct ctdb_event_script *s = &status->script_list->script[i];
+ int ret = 0;
+
+ /*
+ * Occurs when a new script is enabled, it hasn't
+ * been previously run, and a previous script fails
+ */
+ if (s->result == -ENODATA) {
+ continue;
+ }
+
+ /*
+ * Occurs when data for s is from a previous run, so
+ * it was run before the previous script
+ */
+ ret = tevent_timeval_compare(&s->begin, &prev);
+ if (ret == -1) {
+ break;
+ }
+
+ print_status_one(s);
+ prev = s->begin;
}
}
--
Samba Shared Repository