@@ -130,12 +130,8 @@ where
130130 . map ( |( client, consumer) | ( Some ( client) , Some ( consumer) ) )
131131 . unwrap_or_default ( ) ;
132132
133- let supervisor_builder = SupervisorBuilderK8s :: new (
134- agent_id. clone ( ) ,
135- sub_agent_config. clone ( ) ,
136- self . k8s_client . clone ( ) ,
137- self . k8s_config . clone ( ) ,
138- ) ;
133+ let supervisor_builder =
134+ SupervisorBuilderK8s :: new ( self . k8s_client . clone ( ) , self . k8s_config . clone ( ) ) ;
139135
140136 let remote_config_handler = RemoteConfigHandler :: new (
141137 agent_id. clone ( ) ,
@@ -168,22 +164,13 @@ where
168164}
169165
170166pub struct SupervisorBuilderK8s {
171- agent_id : AgentID ,
172- agent_cfg : SubAgentConfig ,
173167 k8s_client : Arc < SyncK8sClient > ,
174168 k8s_config : K8sConfig ,
175169}
176170
177171impl SupervisorBuilderK8s {
178- pub fn new (
179- agent_id : AgentID ,
180- agent_cfg : SubAgentConfig ,
181- k8s_client : Arc < SyncK8sClient > ,
182- k8s_config : K8sConfig ,
183- ) -> Self {
172+ pub fn new ( k8s_client : Arc < SyncK8sClient > , k8s_config : K8sConfig ) -> Self {
184173 Self {
185- agent_id,
186- agent_cfg,
187174 k8s_client,
188175 k8s_config,
189176 }
@@ -197,7 +184,9 @@ impl SupervisorBuilder for SupervisorBuilderK8s {
197184 & self ,
198185 effective_agent : EffectiveAgent ,
199186 ) -> Result < Self :: SupervisorStarter , SubAgentBuilderError > {
200- debug ! ( "Building CR supervisors {}" , & self . agent_id) ;
187+ let agent_id = effective_agent. get_agent_id ( ) . clone ( ) ;
188+ let agent_type = effective_agent. get_agent_type ( ) . clone ( ) ;
189+ debug ! ( "Building supervisors {}:{}" , agent_type, agent_id) ;
201190
202191 let k8s_objects = effective_agent. get_k8s_config ( ) ?;
203192
@@ -221,8 +210,8 @@ impl SupervisorBuilder for SupervisorBuilderK8s {
221210
222211 // Clone the k8s_client on each build.
223212 Ok ( NotStartedSupervisorK8s :: new (
224- self . agent_id . clone ( ) ,
225- self . agent_cfg . agent_type . clone ( ) ,
213+ agent_id,
214+ agent_type,
226215 self . k8s_client . clone ( ) ,
227216 k8s_objects. clone ( ) ,
228217 ) )
@@ -352,8 +341,8 @@ pub mod tests {
352341 } ;
353342
354343 let effective_agent = EffectiveAgent :: new (
355- agent_id. clone ( ) ,
356- sub_agent_config. agent_type . clone ( ) ,
344+ agent_id,
345+ sub_agent_config. agent_type ,
357346 Runtime {
358347 deployment : Deployment {
359348 on_host : None ,
@@ -362,8 +351,7 @@ pub mod tests {
362351 } ,
363352 ) ;
364353
365- let supervisor_builder =
366- testing_supervisor_builder ( agent_id. clone ( ) , sub_agent_config. clone ( ) ) ;
354+ let supervisor_builder = testing_supervisor_builder ( ) ;
367355
368356 let result = supervisor_builder. build_supervisor ( effective_agent) ;
369357 assert ! (
@@ -381,8 +369,8 @@ pub mod tests {
381369 } ;
382370
383371 let effective_agent = EffectiveAgent :: new (
384- agent_id. clone ( ) ,
385- sub_agent_config. agent_type . clone ( ) ,
372+ agent_id,
373+ sub_agent_config. agent_type ,
386374 Runtime {
387375 deployment : Deployment {
388376 on_host : None ,
@@ -391,8 +379,7 @@ pub mod tests {
391379 } ,
392380 ) ;
393381
394- let supervisor_builder =
395- testing_supervisor_builder ( agent_id. clone ( ) , sub_agent_config. clone ( ) ) ;
382+ let supervisor_builder = testing_supervisor_builder ( ) ;
396383
397384 let result = supervisor_builder. build_supervisor ( effective_agent) ;
398385 assert_matches ! (
@@ -483,10 +470,7 @@ pub mod tests {
483470 ( opamp_builder, instance_id_getter, hash_repository_mock)
484471 }
485472
486- fn testing_supervisor_builder (
487- agent_id : AgentID ,
488- sub_agent_config : SubAgentConfig ,
489- ) -> SupervisorBuilderK8s {
473+ fn testing_supervisor_builder ( ) -> SupervisorBuilderK8s {
490474 let mut mock_client = MockSyncK8sClient :: default ( ) ;
491475 mock_client
492476 . expect_default_namespace ( )
@@ -498,11 +482,6 @@ pub mod tests {
498482 cr_type_meta : K8sConfig :: default ( ) . cr_type_meta ,
499483 ..Default :: default ( )
500484 } ;
501- SupervisorBuilderK8s :: new (
502- agent_id,
503- sub_agent_config,
504- Arc :: new ( mock_client) ,
505- k8s_config,
506- )
485+ SupervisorBuilderK8s :: new ( Arc :: new ( mock_client) , k8s_config)
507486 }
508487}
0 commit comments