diff --git a/scripts/policy/frameworks/management/controller/main.zeek b/scripts/policy/frameworks/management/controller/main.zeek index 4a342fe02b..b2407d532f 100644 --- a/scripts/policy/frameworks/management/controller/main.zeek +++ b/scripts/policy/frameworks/management/controller/main.zeek @@ -186,24 +186,6 @@ global g_configs: table[ConfigState] of Management::Configuration function config_deploy_to_agents(config: Management::Configuration, req: Management::Request::Request) { - # Make any final changes to the configuration we send off. - - # If needed, fill in agent IP address info as learned from their peerings. - # XXX this will need revisiting when we support host names. - local instances: set[Management::Instance]; - - for ( inst in config$instances ) - { - if ( inst$name in g_instances_known - && inst$host == 0.0.0.0 - && g_instances_known[inst$name]$host != 0.0.0.0 ) - inst$host = g_instances_known[inst$name]$host; - - add instances[inst]; - } - - config$instances = instances; - for ( name in g_instances ) { if ( name !in g_instances_ready ) @@ -1037,6 +1019,27 @@ event Management::Controller::API::stage_configuration_request(reqid: string, co g_configs[STAGED] = config; config_copy = copy(config); + # The staged config is preserved as the client sent it to us. For the + # ready-to-deploy version we fill in additional details here. + # + # One such bit of information is that we know the IP addresses of + # instances that connected to the controller from their Broker peering. + # + # XXX this will need revisiting when we support host names. + local instances: set[Management::Instance]; + + for ( inst in config_copy$instances ) + { + if ( inst$name in g_instances_known + && inst$host == 0.0.0.0 + && g_instances_known[inst$name]$host != 0.0.0.0 ) + inst$host = g_instances_known[inst$name]$host; + + add instances[inst]; + } + + config_copy$instances = instances; + if ( Management::Controller::auto_assign_broker_ports ) config_assign_broker_ports(config_copy); if ( Management::Controller::auto_assign_metrics_ports )