mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Management framework: move to ResultVec in agent's set_configuration response
We so far reported one result record per agent, which made it hard to report per-node outcomes for the new configuration. Agents now report one result record per node they're responsible for.
This commit is contained in:
parent
83c60fd8ac
commit
49b9f1669c
3 changed files with 29 additions and 13 deletions
|
@ -38,7 +38,7 @@ export {
|
|||
## result: the result record.
|
||||
##
|
||||
global set_configuration_response: event(reqid: string,
|
||||
result: Management::Result);
|
||||
result: Management::ResultVec);
|
||||
|
||||
|
||||
## The controller sends this event to request a list of
|
||||
|
|
|
@ -96,21 +96,34 @@ function agent_topic(): string
|
|||
|
||||
function send_set_configuration_response(req: Management::Request::Request)
|
||||
{
|
||||
local res = Management::Result(
|
||||
$reqid = req$id,
|
||||
$instance = Management::Agent::get_name());
|
||||
local node: string;
|
||||
local res: Management::Result;
|
||||
|
||||
if ( |req$set_configuration_state$nodes_pending| > 0 )
|
||||
# Put together the results vector for the response event.
|
||||
for ( node in g_nodes )
|
||||
{
|
||||
res$success = F;
|
||||
res$error = "some nodes failed to start";
|
||||
res$data = req$set_configuration_state$nodes_pending;
|
||||
res = Management::Result(
|
||||
$reqid = req$id,
|
||||
$instance = Management::Agent::get_name(),
|
||||
$node = node);
|
||||
|
||||
if ( node in req$set_configuration_state$nodes_pending )
|
||||
{
|
||||
# This node failed. Pull in any stdout/stderr context
|
||||
# we might have.
|
||||
res$success = F;
|
||||
|
||||
# XXX fill in stdout/stderr here if possible
|
||||
}
|
||||
|
||||
# Add this result to the overall response
|
||||
req$results[|req$results|] = res;
|
||||
}
|
||||
|
||||
Management::Log::info(fmt("tx Management::Agent::API::set_configuration_response %s",
|
||||
Management::result_to_string(res)));
|
||||
Broker::publish(agent_topic(),
|
||||
Management::Agent::API::set_configuration_response, req$id, res);
|
||||
Management::Agent::API::set_configuration_response, req$id, req$results);
|
||||
|
||||
Management::Request::finish(req$id);
|
||||
|
||||
|
@ -215,7 +228,7 @@ event Management::Agent::API::set_configuration_request(reqid: string, config: M
|
|||
Management::Log::info(fmt("tx Management::Agent::API::set_configuration_response %s",
|
||||
Management::result_to_string(res)));
|
||||
Broker::publish(agent_topic(),
|
||||
Management::Agent::API::set_configuration_response, reqid, res);
|
||||
Management::Agent::API::set_configuration_response, reqid, vector(res));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -346,7 +346,7 @@ event Management::Agent::API::notify_log(instance: string, msg: string, node: st
|
|||
# XXX TODO
|
||||
}
|
||||
|
||||
event Management::Agent::API::set_configuration_response(reqid: string, result: Management::Result)
|
||||
event Management::Agent::API::set_configuration_response(reqid: string, results: Management::ResultVec)
|
||||
{
|
||||
Management::Log::info(fmt("rx Management::Agent::API::set_configuration_response %s", reqid));
|
||||
|
||||
|
@ -363,8 +363,11 @@ event Management::Agent::API::set_configuration_response(reqid: string, result:
|
|||
if ( Management::Request::is_null(req) )
|
||||
return;
|
||||
|
||||
# Add this result to the overall response
|
||||
req$results[|req$results|] = result;
|
||||
# XXX the usual "any" handling needs to happen here if data is filled in
|
||||
|
||||
# Add this agent's results to the overall response
|
||||
for ( i in results )
|
||||
req$results[|req$results|] = results[i];
|
||||
|
||||
# Mark this request as done by removing it from the table of pending
|
||||
# ones. The following if-check should always be true.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue