Management framework: trigger deployment upon when instances are ready

More resilience: when an agent restarts, it checks in with the controller. If
the controller has deployed a config, this check-in may lead to an internal
notify_agents_ready event. At that point, we now trigger a deployment when there
currently isn't already one running. This ensures that any agents not yet
running the current cluster will start to do so, and does nothing when those
agents already run it, since they ignore the request in that case.
This commit is contained in:
Christian Kreibich 2022-06-21 15:25:42 -07:00
parent a622e28eab
commit 68558e2874

View file

@ -668,11 +668,24 @@ function deploy(req: Management::Request::Request)
event Management::Controller::API::notify_agents_ready(instances: set[string])
{
local insts = Management::Util::set_to_vector(instances);
local req: Management::Request::Request;
Management::Log::info(fmt("rx Management::Controller::API:notify_agents_ready %s",
join_string_vec(insts, ", ")));
local req = Management::Request::lookup(g_config_reqid_pending);
# If we're not currently deploying a configuration, but have a deployed
# configuration, trigger a deployment at this point. Some of our agents
# might have restarted, and need to get in sync with us. Agents already
# running this configuration will do nothing.
if ( g_config_reqid_pending == "" && DEPLOYED in g_configs )
{
req = Management::Request::create();
req$deploy_state = DeployState($config=g_configs[DEPLOYED], $is_internal=T);
Management::Log::info(fmt("no deployment in progress, triggering via %s", req$id));
deploy(req);
}
req = Management::Request::lookup(g_config_reqid_pending);
# If there's no pending request, when it's no longer available, or it
# doesn't have config state, don't do anything else.