mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +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.
|
## result: the result record.
|
||||||
##
|
##
|
||||||
global set_configuration_response: event(reqid: string,
|
global set_configuration_response: event(reqid: string,
|
||||||
result: Management::Result);
|
result: Management::ResultVec);
|
||||||
|
|
||||||
|
|
||||||
## The controller sends this event to request a list of
|
## 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)
|
function send_set_configuration_response(req: Management::Request::Request)
|
||||||
{
|
{
|
||||||
local res = Management::Result(
|
local node: string;
|
||||||
$reqid = req$id,
|
local res: Management::Result;
|
||||||
$instance = Management::Agent::get_name());
|
|
||||||
|
|
||||||
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 = Management::Result(
|
||||||
res$error = "some nodes failed to start";
|
$reqid = req$id,
|
||||||
res$data = req$set_configuration_state$nodes_pending;
|
$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::Log::info(fmt("tx Management::Agent::API::set_configuration_response %s",
|
||||||
Management::result_to_string(res)));
|
Management::result_to_string(res)));
|
||||||
Broker::publish(agent_topic(),
|
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);
|
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::Log::info(fmt("tx Management::Agent::API::set_configuration_response %s",
|
||||||
Management::result_to_string(res)));
|
Management::result_to_string(res)));
|
||||||
Broker::publish(agent_topic(),
|
Broker::publish(agent_topic(),
|
||||||
Management::Agent::API::set_configuration_response, reqid, res);
|
Management::Agent::API::set_configuration_response, reqid, vector(res));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -346,7 +346,7 @@ event Management::Agent::API::notify_log(instance: string, msg: string, node: st
|
||||||
# XXX TODO
|
# 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));
|
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) )
|
if ( Management::Request::is_null(req) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
# Add this result to the overall response
|
# XXX the usual "any" handling needs to happen here if data is filled in
|
||||||
req$results[|req$results|] = result;
|
|
||||||
|
# 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
|
# Mark this request as done by removing it from the table of pending
|
||||||
# ones. The following if-check should always be true.
|
# ones. The following if-check should always be true.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue