Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass ai metadata to telemetry during cni image build #3095

Merged
merged 7 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ cni-image: ## build cni container image.
TARGET=$(OS) \
OS=$(OS) \
ARCH=$(ARCH) \
OS_VERSION=$(OS_VERSION)
OS_VERSION=$(OS_VERSION) \
EXTRA_BUILD_ARGS='--build-arg CNI_AI_PATH=$(CNI_AI_PATH) --build-arg CNI_AI_ID=$(CNI_AI_ID)'

cni-image-push: ## push cni container image.
$(MAKE) container-push \
Expand Down
4 changes: 3 additions & 1 deletion cni/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ FROM --platform=linux/${ARCH} mcr.microsoft.com/cbl-mariner/base/core@sha256:a49
FROM go AS azure-vnet
ARG OS
ARG VERSION
ARG CNI_AI_PATH
timraymond marked this conversation as resolved.
Show resolved Hide resolved
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

Expand Down
4 changes: 2 additions & 2 deletions cni/telemetry/service/telemetrymain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
10 changes: 1 addition & 9 deletions telemetry/aiwrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading