diff --git a/Makefile b/Makefile index b647fa05b5..1eb8a0eee0 100644 --- a/Makefile +++ b/Makefile @@ -425,7 +425,7 @@ cni-image: ## build cni container image. $(MAKE) container \ DOCKERFILE=cni/$(OS).Dockerfile \ IMAGE=$(CNI_IMAGE) \ - EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH) --build-arg OS_VERSION=$(OS_VERSION)' \ + EXTRA_BUILD_ARGS='--build-arg OS=$(OS) --build-arg ARCH=$(ARCH) --build-arg OS_VERSION=$(OS_VERSION) --build-arg CNI_AI_PATH=$(CNI_AI_PATH) --build-arg CNI_AI_ID=$(CNI_AI_ID)' \ PLATFORM=$(PLATFORM) \ TAG=$(CNI_PLATFORM_TAG) \ OS=$(OS) \ diff --git a/cni/linux.Dockerfile b/cni/linux.Dockerfile index b38b88b8af..8cdbea07e0 100644 --- a/cni/linux.Dockerfile +++ b/cni/linux.Dockerfile @@ -6,10 +6,12 @@ ARG OS FROM mcr.microsoft.com/oss/go/microsoft/golang:1.22 AS azure-vnet ARG OS ARG VERSION +ARG CNI_AI_PATH +ARG CNI_AI_ID WORKDIR /azure-container-networking COPY . . RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/plugin/main.go -RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-telemetry -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/telemetry/service/telemetrymain.go +RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-telemetry -trimpath -ldflags "-X main.version="$VERSION" -X "$CNI_AI_PATH"="$CNI_AI_ID"" -gcflags="-dwarflocationlists=true" cni/telemetry/service/telemetrymain.go RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-ipam -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/ipam/plugin/main.go RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azurecni-stateless -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/stateless/main.go diff --git a/cni/telemetry/service/telemetrymain.go b/cni/telemetry/service/telemetrymain.go index bf21571d0b..8c278eafe2 100644 --- a/cni/telemetry/service/telemetrymain.go +++ b/cni/telemetry/service/telemetrymain.go @@ -167,8 +167,8 @@ func main() { GetEnvRetryWaitTimeInSecs: config.GetEnvRetryWaitTimeInSecs, } - if tb.CreateAITelemetryHandle(aiConfig, config.DisableAll, config.DisableTrace, config.DisableMetric) != nil { - logger.Error("AI Handle creation error", zap.Error(err)) + if err := tb.CreateAITelemetryHandle(aiConfig, config.DisableAll, config.DisableTrace, config.DisableMetric); err != nil { // nolint + logger.Error("AI Handle creation error:", zap.Error(err)) } logger.Info("Report to host interval", zap.Duration("seconds", config.ReportToHostIntervalInSeconds)) tb.PushData(context.Background()) diff --git a/cni/windows.Dockerfile b/cni/windows.Dockerfile index a464a700c9..e1af11b9a0 100644 --- a/cni/windows.Dockerfile +++ b/cni/windows.Dockerfile @@ -6,10 +6,12 @@ ARG OS_VERSION FROM --platform=linux/${ARCH} mcr.microsoft.com/oss/go/microsoft/golang:1.22 AS azure-vnet ARG OS ARG VERSION +ARG CNI_AI_PATH +ARG CNI_AI_ID WORKDIR /azure-container-networking COPY . . RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/plugin/main.go -RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-telemetry -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/telemetry/service/telemetrymain.go +RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-telemetry -trimpath -ldflags "-X main.version="$VERSION" -X "$CNI_AI_PATH"="$CNI_AI_ID"" -gcflags="-dwarflocationlists=true" cni/telemetry/service/telemetrymain.go RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-ipam -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/ipam/plugin/main.go RUN GOOS=$OS CGO_ENABLED=0 go build -a -o /go/bin/azure-vnet-stateless -trimpath -ldflags "-X main.version="$VERSION"" -gcflags="-dwarflocationlists=true" cni/network/stateless/main.go diff --git a/cns/service/main.go b/cns/service/main.go index 1cd19ffd20..d986964a12 100644 --- a/cns/service/main.go +++ b/cns/service/main.go @@ -684,7 +684,7 @@ func main() { } if telemetryDaemonEnabled { - log.Printf("CNI Telemtry is enabled") + logger.Printf("CNI Telemetry is enabled") go startTelemetryService(rootCtx) } diff --git a/telemetry/aiwrapper_test.go b/telemetry/aiwrapper_test.go index c10e39fe70..326e99f55d 100644 --- a/telemetry/aiwrapper_test.go +++ b/telemetry/aiwrapper_test.go @@ -17,15 +17,7 @@ func TestCreateAITelemetryHandle(t *testing.T) { wantErr bool }{ { - name: "disable telemetry", - aiConfig: aitelemetry.AIConfig{}, - disableAll: false, - disableMetric: true, - disableTrace: true, - wantErr: true, - }, - { - name: "empty aiconfig", + name: "disabled telemetry with empty aiconfig", aiConfig: aitelemetry.AIConfig{}, disableAll: true, disableMetric: true,