@@ -100,7 +100,7 @@ use crate::{
100
100
use crate :: {
101
101
ebpf_dispatcher:: EbpfCollector ,
102
102
platform:: {
103
- kubernetes:: { GenericPoller , Poller } ,
103
+ kubernetes:: { GenericPoller , Poller , SidecarPoller } ,
104
104
ApiWatcher , LibvirtXmlExtractor , SocketSynchronizer ,
105
105
} ,
106
106
utils:: {
@@ -530,7 +530,7 @@ impl Trident {
530
530
monitor. start ( ) ;
531
531
532
532
#[ cfg( target_os = "linux" ) ]
533
- let ( libvirt_xml_extractor, platform_synchronizer) = {
533
+ let ( libvirt_xml_extractor, platform_synchronizer, sidecar_poller ) = {
534
534
let ext = Arc :: new ( LibvirtXmlExtractor :: new ( ) ) ;
535
535
let syn = Arc :: new ( PlatformSynchronizer :: new (
536
536
runtime. clone ( ) ,
@@ -548,7 +548,17 @@ impl Trident {
548
548
HashMap :: new ( ) ,
549
549
) ) ;
550
550
ext. start ( ) ;
551
- ( ext, syn)
551
+ let poller = if sidecar_mode {
552
+ let p: Arc < GenericPoller > = Arc :: new (
553
+ SidecarPoller :: new ( config_handler. static_config . controller_ips [ 0 ] . parse ( ) ?)
554
+ . into ( ) ,
555
+ ) ;
556
+ syn. set_kubernetes_poller ( p. clone ( ) ) ;
557
+ Some ( p)
558
+ } else {
559
+ None
560
+ } ;
561
+ ( ext, syn, poller)
552
562
} ;
553
563
#[ cfg( target_os = "windows" ) ]
554
564
let platform_synchronizer = Arc :: new ( PlatformSynchronizer :: new (
@@ -708,6 +718,8 @@ impl Trident {
708
718
libvirt_xml_extractor. clone ( ) ,
709
719
platform_synchronizer. clone ( ) ,
710
720
#[ cfg( target_os = "linux" ) ]
721
+ sidecar_poller. clone ( ) ,
722
+ #[ cfg( target_os = "linux" ) ]
711
723
api_watcher. clone ( ) ,
712
724
vm_mac_addrs,
713
725
config_handler. static_config . agent_mode ,
@@ -1375,6 +1387,7 @@ impl AgentComponents {
1375
1387
remote_log_config : RemoteLogConfig ,
1376
1388
#[ cfg( target_os = "linux" ) ] libvirt_xml_extractor : Arc < LibvirtXmlExtractor > ,
1377
1389
platform_synchronizer : Arc < PlatformSynchronizer > ,
1390
+ #[ cfg( target_os = "linux" ) ] sidecar_poller : Option < Arc < GenericPoller > > ,
1378
1391
#[ cfg( target_os = "linux" ) ] api_watcher : Arc < ApiWatcher > ,
1379
1392
vm_mac_addrs : Vec < MacAddr > ,
1380
1393
agent_mode : RunningMode ,
@@ -1469,18 +1482,19 @@ impl AgentComponents {
1469
1482
// TODO: packet handler builders
1470
1483
1471
1484
#[ cfg( target_os = "linux" ) ]
1472
- let kubernetes_poller = Arc :: new ( GenericPoller :: new (
1473
- config_handler. static_config . controller_ips [ 0 ] . parse ( ) ?,
1474
- config_handler. platform ( ) ,
1475
- config_handler
1476
- . candidate_config
1477
- . dispatcher
1478
- . extra_netns_regex
1479
- . clone ( ) ,
1480
- sidecar_mode,
1481
- ) ) ;
1482
- #[ cfg( target_os = "linux" ) ]
1483
- platform_synchronizer. set_kubernetes_poller ( kubernetes_poller. clone ( ) ) ;
1485
+ // sidecar poller is created before agent start to provide pod interface info for server
1486
+ let kubernetes_poller = sidecar_poller. unwrap_or_else ( || {
1487
+ let poller = Arc :: new ( GenericPoller :: new (
1488
+ config_handler. platform ( ) ,
1489
+ config_handler
1490
+ . candidate_config
1491
+ . dispatcher
1492
+ . extra_netns_regex
1493
+ . clone ( ) ,
1494
+ ) ) ;
1495
+ platform_synchronizer. set_kubernetes_poller ( poller. clone ( ) ) ;
1496
+ poller
1497
+ } ) ;
1484
1498
1485
1499
#[ cfg( target_os = "linux" ) ]
1486
1500
let prometheus_targets_watcher = Arc :: new ( TargetsWatcher :: new (
@@ -2563,6 +2577,7 @@ impl Components {
2563
2577
remote_log_config : RemoteLogConfig ,
2564
2578
#[ cfg( target_os = "linux" ) ] libvirt_xml_extractor : Arc < LibvirtXmlExtractor > ,
2565
2579
platform_synchronizer : Arc < PlatformSynchronizer > ,
2580
+ #[ cfg( target_os = "linux" ) ] sidecar_poller : Option < Arc < GenericPoller > > ,
2566
2581
#[ cfg( target_os = "linux" ) ] api_watcher : Arc < ApiWatcher > ,
2567
2582
vm_mac_addrs : Vec < MacAddr > ,
2568
2583
agent_mode : RunningMode ,
@@ -2597,6 +2612,8 @@ impl Components {
2597
2612
libvirt_xml_extractor,
2598
2613
platform_synchronizer,
2599
2614
#[ cfg( target_os = "linux" ) ]
2615
+ sidecar_poller,
2616
+ #[ cfg( target_os = "linux" ) ]
2600
2617
api_watcher,
2601
2618
vm_mac_addrs,
2602
2619
agent_mode,
0 commit comments