Skip to content

Commit fd76e5a

Browse files
committed
replace nwcfg subcontext with containerid for correlation
1 parent 77de27f commit fd76e5a

File tree

5 files changed

+19
-27
lines changed

5 files changed

+19
-27
lines changed

cni/network/network.go

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -294,12 +294,10 @@ func (plugin *NetPlugin) getPodInfo(args string) (name, ns string, err error) {
294294
return k8sPodName, k8sNamespace, nil
295295
}
296296

297-
func (plugin *NetPlugin) setCNIReportDetails(nwCfg *cni.NetworkConfig, opType, msg string) {
297+
func (plugin *NetPlugin) setCNIReportDetails(containerID string, opType, msg string) {
298298
telemetry.CNIReportSettings.OperationType = opType
299-
telemetry.CNIReportSettings.SubContext = fmt.Sprintf("%+v", nwCfg)
299+
telemetry.CNIReportSettings.SubContext = containerID
300300
telemetry.CNIReportSettings.EventMessage = msg
301-
telemetry.CNIReportSettings.BridgeDetails.NetworkMode = nwCfg.Mode
302-
telemetry.CNIReportSettings.InterfaceDetails.SecondaryCAUsedCount = plugin.nm.GetNumberOfEndpoints("", nwCfg.Name)
303301
telemetry.CNIReportSettings.Version = plugin.Version
304302
}
305303

@@ -367,8 +365,6 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
367365
zap.Any("args", args.Args),
368366
zap.String("path", args.Path),
369367
zap.ByteString("stdinData", args.StdinData))
370-
telemetry.SendEvent(fmt.Sprintf("[cni-net] Processing ADD command with args {ContainerID:%v Netns:%v IfName:%v Args:%v Path:%v StdinData:%s}.",
371-
args.ContainerID, args.Netns, args.IfName, args.Args, args.Path, args.StdinData))
372368

373369
// Parse network configuration from stdin.
374370
nwCfg, err := cni.ParseNetworkConfig(args.StdinData)
@@ -382,8 +378,11 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error {
382378
return err
383379
}
384380

381+
plugin.setCNIReportDetails(args.ContainerID, CNI_ADD, "")
382+
telemetry.SendEvent(fmt.Sprintf("[cni-net] Processing ADD command with args {ContainerID:%v Netns:%v IfName:%v Args:%v Path:%v StdinData:%s}.",
383+
args.ContainerID, args.Netns, args.IfName, args.Args, args.Path, args.StdinData))
384+
385385
iptables.DisableIPTableLock = nwCfg.DisableIPTableLock
386-
plugin.setCNIReportDetails(nwCfg, CNI_ADD, "")
387386

388387
defer func() {
389388
// Add Interfaces to result.
@@ -966,8 +965,6 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
966965
zap.Any("args", args.Args),
967966
zap.String("path", args.Path),
968967
zap.ByteString("stdinData", args.StdinData))
969-
telemetry.SendEvent(fmt.Sprintf("[cni-net] Processing DEL command with args {ContainerID:%v Netns:%v IfName:%v Args:%v Path:%v, StdinData:%s}.",
970-
args.ContainerID, args.Netns, args.IfName, args.Args, args.Path, args.StdinData))
971968

972969
defer func() {
973970
logger.Info("DEL command completed",
@@ -992,8 +989,10 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {
992989
logger.Error("Failed to get POD info", zap.Error(err))
993990
}
994991

995-
plugin.setCNIReportDetails(nwCfg, CNI_DEL, "")
992+
plugin.setCNIReportDetails(args.ContainerID, CNI_DEL, "")
996993
telemetry.CNIReportSettings.ContainerName = k8sPodName + ":" + k8sNamespace
994+
telemetry.SendEvent(fmt.Sprintf("[cni-net] Processing DEL command with args {ContainerID:%v Netns:%v IfName:%v Args:%v Path:%v, StdinData:%s}.",
995+
args.ContainerID, args.Netns, args.IfName, args.Args, args.Path, args.StdinData))
997996

998997
iptables.DisableIPTableLock = nwCfg.DisableIPTableLock
999998

@@ -1186,7 +1185,7 @@ func (plugin *NetPlugin) Update(args *cniSkel.CmdArgs) error {
11861185
logger.Info("Read network configuration", zap.Any("config", nwCfg))
11871186

11881187
iptables.DisableIPTableLock = nwCfg.DisableIPTableLock
1189-
plugin.setCNIReportDetails(nwCfg, CNI_UPDATE, "")
1188+
plugin.setCNIReportDetails(args.ContainerID, CNI_UPDATE, "")
11901189

11911190
defer func() {
11921191
if result == nil {
@@ -1335,7 +1334,7 @@ func (plugin *NetPlugin) Update(args *cniSkel.CmdArgs) error {
13351334
}
13361335

13371336
msg := fmt.Sprintf("CNI UPDATE succeeded : Updated %+v podname %v namespace %v", targetNetworkConfig, k8sPodName, k8sNamespace)
1338-
plugin.setCNIReportDetails(nwCfg, CNI_UPDATE, msg)
1337+
plugin.setCNIReportDetails(args.ContainerID, CNI_UPDATE, msg)
13391338

13401339
return nil
13411340
}

cni/network/plugin/main.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,10 @@ func rootExecute() error {
7676
HostNetAgentURL: hostNetAgentURL,
7777
ContentType: telemetry.ContentType,
7878
Report: &telemetry.CNIReport{
79-
Context: "AzureCNI",
80-
SystemDetails: telemetry.SystemInfo{},
81-
InterfaceDetails: telemetry.InterfaceInfo{},
82-
BridgeDetails: telemetry.BridgeInfo{},
83-
Version: version,
84-
Logger: logger,
79+
Context: "AzureCNI",
80+
SystemDetails: telemetry.SystemInfo{},
81+
Version: version,
82+
Logger: logger,
8583
},
8684
}
8785

cni/network/stateless/main.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,9 @@ func rootExecute() error {
8282
HostNetAgentURL: hostNetAgentURL,
8383
ContentType: telemetry.ContentType,
8484
Report: &telemetry.CNIReport{
85-
Context: "AzureCNI",
86-
SystemDetails: telemetry.SystemInfo{},
87-
InterfaceDetails: telemetry.InterfaceInfo{},
88-
BridgeDetails: telemetry.BridgeInfo{},
89-
Version: version,
85+
Context: "AzureCNI",
86+
SystemDetails: telemetry.SystemInfo{},
87+
Version: version,
9088
},
9189
}
9290

network/manager.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,9 @@ func (nm *networkManager) UpdateEndpointState(eps []*endpoint) error {
429429
zap.String("hostVethName", ipinfo.HostVethName), zap.String("macAddress", ipinfo.MacAddress), zap.String("nicType", string(ipinfo.NICType)))
430430
ifNameToIPInfoCopy[key] = *ipinfo
431431
}
432-
telemetry.SendEvent(fmt.Sprintf("Stateless CNI update endpoint state with: %+v", ifNameToIPInfoCopy))
433-
434432
// we assume all endpoints have the same container id
435433
cnsEndpointID := eps[0].ContainerID
434+
telemetry.SendEvent(fmt.Sprintf("Stateless CNI update endpoint state for %s with: %+v ", cnsEndpointID, ifNameToIPInfoCopy))
436435
if err := validateUpdateEndpointState(cnsEndpointID, ifnameToIPInfoMap); err != nil {
437436
return errors.Wrap(err, "failed to validate update endpoint state that will be sent to cns")
438437
}

telemetry/telemetry.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,6 @@ type CNIReport struct {
7979
VnetAddressSpace []string
8080
OSDetails OSInfo
8181
SystemDetails SystemInfo
82-
InterfaceDetails InterfaceInfo
83-
BridgeDetails BridgeInfo
8482
Metadata common.Metadata `json:"compute"`
8583
Logger *zap.Logger
8684
}

0 commit comments

Comments
 (0)