@@ -326,7 +326,6 @@ func (plugin *NetPlugin) addIpamInvoker(ipamAddConfig IPAMAddConfig) (IPAMAddRes
326326 if err != nil {
327327 return IPAMAddResult {}, errors .Wrap (err , "failed to add ipam invoker" )
328328 }
329- telemetry .SendEvent (fmt .Sprintf ("Allocated IPAddress from ipam interface: %+v" , ipamAddResult .PrettyString ()))
330329 return ipamAddResult , nil
331330}
332331
@@ -432,7 +431,7 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
432431 zap .Any ("IPs" , cniResult .IPs ),
433432 zap .Error (log .NewErrorWithoutStackTrace (err )))
434433
435- telemetry .SendEvent (fmt .Sprintf ("ADD command completed for ipamAddResult verbose : %s epInfos: %s error: %v " , ipamAddResult .PrettyString (), network .FormatStructPointers (epInfos ), err ))
434+ telemetry .SendEvent (fmt .Sprintf ("ADD command completed with [ ipamAddResult] : %s [ epInfos] : %s [ error] : %v " , ipamAddResult .PrettyString (), network .FormatStructPointers (epInfos ), err ))
436435 }()
437436
438437 ipamAddResult = IPAMAddResult {interfaceInfo : make (map [string ]network.InterfaceInfo )}
@@ -538,15 +537,9 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
538537 if err != nil {
539538 return fmt .Errorf ("IPAM Invoker Add failed with error: %w" , err )
540539 }
541-
542- // TODO: This proably needs to be changed as we return all interfaces...
543- // sendEvent(plugin, fmt.Sprintf("Allocated IPAddress from ipam DefaultInterface: %+v, SecondaryInterfaces: %+v", ipamAddResult.interfaceInfo[ifIndex], ipamAddResult.interfaceInfo))
544540 }
545541
546542 policies := cni .GetPoliciesFromNwCfg (nwCfg .AdditionalArgs )
547- // moved to addIpamInvoker
548- // sendEvent(plugin, fmt.Sprintf("Allocated IPAddress from ipam interface: %+v", ipamAddResult.PrettyString()))
549-
550543 defer func () { //nolint:gocritic
551544 if err != nil {
552545 // for swift v1 multi-tenancies scenario, CNI is not supposed to invoke CNS for cleaning Ips
@@ -980,6 +973,7 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
980973 logger .Info ("DEL command completed" ,
981974 zap .String ("pod" , k8sPodName ),
982975 zap .Error (log .NewErrorWithoutStackTrace (err )))
976+ telemetry .SendEvent (fmt .Sprintf ("DEL command completed: [released ip]: %+v [podname]: %s [namespace]: %s [error]: %v" , nwCfg .IPAM .Address , k8sPodName , k8sNamespace , err ))
983977 }()
984978
985979 // Parse network configuration from stdin.
@@ -1096,13 +1090,13 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
10961090 if len (epInfos ) == 0 {
10971091 endpointID := plugin .nm .GetEndpointID (args .ContainerID , args .IfName )
10981092 if ! nwCfg .MultiTenancy {
1099- logger .Error ( "Failed to query endpoint" ,
1093+ logger .Warn ( "Could not query endpoint" ,
11001094 zap .String ("endpoint" , endpointID ),
11011095 zap .Error (err ))
11021096
1103- logger .Error ("Release ip by ContainerID (endpoint not found)" ,
1097+ logger .Warn ("Release ip by ContainerID (endpoint not found)" ,
11041098 zap .String ("containerID" , args .ContainerID ))
1105- telemetry .SendEvent (fmt .Sprintf ("Release ip by ContainerID (endpoint not found):%v " , args .ContainerID ))
1099+ telemetry .SendEvent (fmt .Sprintf ("Release ip by ContainerID (endpoint not found): %s " , args .ContainerID ))
11061100 if err = plugin .ipamInvoker .Delete (nil , nwCfg , args , nwInfo .Options ); err != nil {
11071101 return plugin .RetriableError (fmt .Errorf ("failed to release address(no endpoint): %w" , err ))
11081102 }
@@ -1129,14 +1123,13 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
11291123 for _ , epInfo := range epInfos {
11301124 logger .Info ("Deleting endpoint" ,
11311125 zap .String ("endpointID" , epInfo .EndpointID ))
1132- telemetry .SendEvent (fmt .Sprintf ("Deleting endpoint:%v" , epInfo .EndpointID ))
11331126
11341127 if ! nwCfg .MultiTenancy && (epInfo .NICType == cns .InfraNIC || epInfo .NICType == "" ) {
11351128 // Delegated/secondary nic ips are statically allocated so we don't need to release
11361129 // Call into IPAM plugin to release the endpoint's addresses.
11371130 for i := range epInfo .IPAddresses {
11381131 logger .Info ("Release ip" , zap .String ("ip" , epInfo .IPAddresses [i ].IP .String ()))
1139- telemetry .SendEvent (fmt .Sprintf ("Release ip:%s " , epInfo .IPAddresses [i ].IP .String ()))
1132+ telemetry .SendEvent (fmt .Sprintf ("Release ip: %s container id: %s endpoint id: %s " , epInfo .IPAddresses [i ].IP .String (), args . ContainerID , epInfo . EndpointID ))
11401133 err = plugin .ipamInvoker .Delete (& epInfo .IPAddresses [i ], nwCfg , args , nwInfo .Options )
11411134 if err != nil {
11421135 return plugin .RetriableError (fmt .Errorf ("failed to release address: %w" , err ))
@@ -1145,6 +1138,7 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
11451138 } else if epInfo .EnableInfraVnet { // remove in future PR
11461139 nwCfg .IPAM .Subnet = nwInfo .Subnets [0 ].Prefix .String ()
11471140 nwCfg .IPAM .Address = epInfo .InfraVnetIP .IP .String ()
1141+ telemetry .SendEvent (fmt .Sprintf ("Deleting infra vnet endpoint: container id: %s endpoint id: %s subnet: %s address: %s" , args .ContainerID , epInfo .EndpointID , nwCfg .IPAM .Subnet , nwCfg .IPAM .Address ))
11481142 err = plugin .ipamInvoker .Delete (nil , nwCfg , args , nwInfo .Options )
11491143 if err != nil {
11501144 return plugin .RetriableError (fmt .Errorf ("failed to release address: %w" , err ))
@@ -1156,7 +1150,6 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
11561150 if err != nil {
11571151 return plugin .RetriableError (fmt .Errorf ("failed to save state: %w" , err ))
11581152 }
1159- telemetry .SendEvent (fmt .Sprintf ("CNI DEL succeeded : Released ip %+v podname %v namespace %v" , nwCfg .IPAM .Address , k8sPodName , k8sNamespace ))
11601153
11611154 return err
11621155}
0 commit comments