Skip to content

Commit

Permalink
address linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
QxBytes committed Nov 14, 2024
1 parent d341612 commit 23e8b82
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions cni/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (plugin *NetPlugin) getPodInfo(args string) (name, ns string, err error) {
return k8sPodName, k8sNamespace, nil
}

func (plugin *NetPlugin) setCNIReportDetails(containerID string, opType, msg string) {
func (plugin *NetPlugin) setCNIReportDetails(containerID, opType, msg string) {
telemetry.CNIReportSettings.OperationType = opType
telemetry.CNIReportSettings.SubContext = containerID
telemetry.CNIReportSettings.EventMessage = msg
Expand Down Expand Up @@ -1095,7 +1095,7 @@ func (plugin *NetPlugin) Delete(args *cniSkel.CmdArgs) error {

logger.Warn("Release ip by ContainerID (endpoint not found)",
zap.String("containerID", args.ContainerID))
telemetry.SendEvent(fmt.Sprintf("Release ip by ContainerID (endpoint not found): %s", args.ContainerID))
telemetry.SendEvent("Release ip by ContainerID (endpoint not found): " + args.ContainerID)
if err = plugin.ipamInvoker.Delete(nil, nwCfg, args, nwInfo.Options); err != nil {
return plugin.RetriableError(fmt.Errorf("failed to release address(no endpoint): %w", err))
}
Expand Down
4 changes: 3 additions & 1 deletion cni/telemetry/client/telemetry_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,25 @@ func (c *TelemetryClient) DisconnectTelemetry() {
}
c.tb.Close()
}

func (c *TelemetryClient) sendTelemetry(msg string) {
if c.tb == nil {
return
}
c.lock.Lock()
defer c.lock.Unlock()
c.CNIReportSettings.EventMessage = msg
eventMsg := fmt.Sprintf("[%d] %s", os.Getpid(), msg)
c.CNIReportSettings.EventMessage = eventMsg
telemetry.SendCNIEvent(c.tb, c.CNIReportSettings)
}

func (c *TelemetryClient) sendLog(msg string) {
if c.logger == nil {
return
}
c.logger.Info("Telemetry Event", zap.String("message", msg))
}

func (c *TelemetryClient) SendEvent(msg string) {
c.sendLog(msg)
c.sendTelemetry(msg)
Expand Down
2 changes: 1 addition & 1 deletion network/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ func (nw *network) deleteEndpointImplHnsV2(ep *endpoint) error {
}

logger.Info("Deleting hcn endpoint with id", zap.String("HnsId", ep.HnsId))
telemetry.SendEvent(fmt.Sprintf("Deleting HCN endpoint: %s", ep.HnsId))
telemetry.SendEvent("Deleting HCN endpoint: " + ep.HnsId)

hcnEndpoint, err = Hnsv2.GetEndpointByID(ep.HnsId)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion network/network_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (nm *networkManager) deleteNetworkImplHnsV2(nw *network) error {
var hcnNetwork *hcn.HostComputeNetwork
var err error
logger.Info("Deleting hcn network with id", zap.String("id", nw.HnsId))
telemetry.SendEvent(fmt.Sprintf("Deleting HCN network: %s", nw.HnsId))
telemetry.SendEvent("Deleting HCN network: " + nw.HnsId)

if hcnNetwork, err = Hnsv2.GetNetworkByID(nw.HnsId); err != nil {
return fmt.Errorf("Failed to get hcn network with id: %s due to err: %v", nw.HnsId, err)
Expand Down

0 comments on commit 23e8b82

Please sign in to comment.