Skip to content

Network operator version configuration#251

Merged
Tzvonimir merged 1 commit intomainfrom
tzvonimir/network-operator-version
Jan 20, 2026
Merged

Network operator version configuration#251
Tzvonimir merged 1 commit intomainfrom
tzvonimir/network-operator-version

Conversation

@Tzvonimir
Copy link
Contributor

@Tzvonimir Tzvonimir commented Jan 20, 2026

Network operator version configuration

📚 Description of Changes

Provide an overview of your changes and why they’re needed. Link to any related issues (e.g., "Fixes #123"). If your PR fixes a bug, resolves a feature request, or updates documentation, please explain how.

  • What Changed:
    (Describe the modifications, additions, or removals.)

  • Why This Change:
    (Explain the problem this PR addresses or the improvement it provides.)

  • Affected Components:
    (Which component does this change affect? - put x for all components)

  • Compose

  • K8s

  • Other (please specify)

❓ Motivation and Context

Why is this change required? What problem does it solve?

  • Context:
    (Provide background information or link to related discussions/issues.)

  • Relevant Tasks/Issues:
    (e.g., Fixes: #GitHub Issue)

🔍 Types of Changes

Indicate which type of changes your code introduces (check all that apply):

  • BUGFIX: Non-breaking fix for an issue.
  • NEW FEATURE: Non-breaking addition of functionality.
  • BREAKING CHANGE: Fix or feature that causes existing functionality to not work as expected.
  • ENHANCEMENT: Improvement to existing functionality.
  • CHORE: Changes that do not affect production (e.g., documentation, build tooling, CI).

🔬 QA / Verification Steps

Describe the steps a reviewer should take to verify your changes:

  1. (Step one: e.g., "Run make test to verify all tests pass.")
  2. (Step two: e.g., "Deploy to a Kind cluster with make create-kind && make deploy.")
  3. (Additional steps as needed.)

✅ Global Checklist

Please check all boxes that apply:

  • I have read and followed the CONTRIBUTING guidelines.
  • My code follows the code style of this project.
  • I have updated the documentation as needed.
  • I have added tests that cover my changes.
  • All new and existing tests have passed locally.
  • I have run this code in a local environment to verify functionality.
  • I have considered the security implications of this change.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added version tracking to network traffic metrics, including operator version and build commit information for improved deployment visibility across monitoring instances.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 20, 2026

📝 Walkthrough

Walkthrough

This pull request adds version metadata tracking to the network monitor application. The Dockerfile is enhanced to inject build-time version information (major, minor, patch, commit hash, tree state, and build date) through ldflags during compilation. The application code retrieves this version data and propagates it through the monitor configuration to network traffic metrics requests.

Changes

Cohort / File(s) Summary
Build versioning
Dockerfile.netmon
Added ARG declarations for MAJOR, MINOR, PATCH, COMMIT_HASH, GIT_TREE_STATE, and BUILD_DATE. Enhanced Go build command to inject version metadata via ldflags and dynamically capture Go version (GO_VERSION) for embedding in the binary.
Version initialization and propagation
cmd/zxporter-netmon/main.go, internal/networkmonitor/monitor.go
Imported internal version package and retrieved version info in main(). Added OperatorVersion and OperatorCommit fields to Config struct. These fields are populated during initialization and passed as pointers to SendNetworkTrafficMetricsRequest.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 With versions woven through the build,
From Dockerfile to code, metadata fulfilled,
Each operator now knows its birth and commit,
In network metrics where version bits fit,
A rabbit hops forward with traceability lit! 🌟

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The linked issue #123 concerns 'cluster snapshot enum name fix', which is unrelated to the network operator version configuration changes in this PR. Verify that the correct issues are linked to this PR. The current link to issue #123 appears incorrect or unrelated to the version configuration changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Network operator version configuration' accurately summarizes the main change: adding version configuration fields to the network operator.
Out of Scope Changes check ✅ Passed All changes are focused on adding version configuration to the network operator across Dockerfile, main.go, and monitor.go files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@Dockerfile.netmon`:
- Around line 32-40: The GO_VERSION is empty because ${GO_VERSION} is expanded
by the shell before the inline assignment; fix by computing GO_VERSION in the
same shell session before running go build (e.g., run GO_VERSION=$(go version |
awk '{print $3}') && then run CGO_ENABLED=0 ... go build ...) so that the
-ldflags value for github.com/devzero-inc/zxporter/internal/version.goVersion
uses the populated GO_VERSION; update the RUN that invokes go build (referencing
GO_VERSION, go build, and the ldflags key version.goVersion) to perform the
assignment first in the same RUN command.

Comment on lines +32 to +40
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} GO_VERSION=$(go version | awk '{print $3}') go build \
-ldflags "-X github.com/devzero-inc/zxporter/internal/version.major=${MAJOR} \
-X github.com/devzero-inc/zxporter/internal/version.minor=${MINOR} \
-X github.com/devzero-inc/zxporter/internal/version.patch=${PATCH} \
-X github.com/devzero-inc/zxporter/internal/version.gitCommit=${COMMIT_HASH} \
-X github.com/devzero-inc/zxporter/internal/version.gitTreeState=${GIT_TREE_STATE} \
-X github.com/devzero-inc/zxporter/internal/version.buildDate=${BUILD_DATE} \
-X github.com/devzero-inc/zxporter/internal/version.goVersion=${GO_VERSION}" \
-a -o zxporter-netmon cmd/zxporter-netmon/main.go
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify that prefixed env vars aren't available during shell expansion
echo "Test 1 - prefixed var (should be empty):"
TEST_VAR=hello echo "Value: ${TEST_VAR}"

echo ""
echo "Test 2 - exported var (should show 'hello'):"
export TEST_VAR=hello && echo "Value: ${TEST_VAR}"

Repository: devzero-inc/zxporter

Length of output: 171


🏁 Script executed:

#!/bin/bash
# Simulate Docker's RUN behavior
echo "Test 3 - Docker /bin/sh -c with prefixed var:"
/bin/sh -c 'TEST_VAR=hello echo "Value: ${TEST_VAR}"'

echo ""
echo "Test 4 - Docker /bin/sh -c with export:"
/bin/sh -c 'export TEST_VAR=hello && echo "Value: ${TEST_VAR}"'

Repository: devzero-inc/zxporter

Length of output: 171


Shell variable expansion issue: GO_VERSION will be empty in ldflags.

The GO_VERSION=$(...) assignment as an environment variable prefix only affects the environment of go build, but ${GO_VERSION} in the ldflags string is expanded by the shell before the command runs—at which point the variable is unset in the current shell context. This results in goVersion being injected as an empty string at build time.

🔧 Proposed fix
-RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} GO_VERSION=$(go version | awk '{print $3}') go build \
+RUN export GO_VERSION=$(go version | awk '{print $3}') && \
+    CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
     -ldflags "-X github.com/devzero-inc/zxporter/internal/version.major=${MAJOR} \
     -X github.com/devzero-inc/zxporter/internal/version.minor=${MINOR} \
     -X github.com/devzero-inc/zxporter/internal/version.patch=${PATCH} \
     -X github.com/devzero-inc/zxporter/internal/version.gitCommit=${COMMIT_HASH} \
     -X github.com/devzero-inc/zxporter/internal/version.gitTreeState=${GIT_TREE_STATE} \
     -X github.com/devzero-inc/zxporter/internal/version.buildDate=${BUILD_DATE} \
     -X github.com/devzero-inc/zxporter/internal/version.goVersion=${GO_VERSION}" \
     -a -o zxporter-netmon cmd/zxporter-netmon/main.go
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} GO_VERSION=$(go version | awk '{print $3}') go build \
-ldflags "-X github.com/devzero-inc/zxporter/internal/version.major=${MAJOR} \
-X github.com/devzero-inc/zxporter/internal/version.minor=${MINOR} \
-X github.com/devzero-inc/zxporter/internal/version.patch=${PATCH} \
-X github.com/devzero-inc/zxporter/internal/version.gitCommit=${COMMIT_HASH} \
-X github.com/devzero-inc/zxporter/internal/version.gitTreeState=${GIT_TREE_STATE} \
-X github.com/devzero-inc/zxporter/internal/version.buildDate=${BUILD_DATE} \
-X github.com/devzero-inc/zxporter/internal/version.goVersion=${GO_VERSION}" \
-a -o zxporter-netmon cmd/zxporter-netmon/main.go
RUN export GO_VERSION=$(go version | awk '{print $3}') && \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build \
-ldflags "-X github.com/devzero-inc/zxporter/internal/version.major=${MAJOR} \
-X github.com/devzero-inc/zxporter/internal/version.minor=${MINOR} \
-X github.com/devzero-inc/zxporter/internal/version.patch=${PATCH} \
-X github.com/devzero-inc/zxporter/internal/version.gitCommit=${COMMIT_HASH} \
-X github.com/devzero-inc/zxporter/internal/version.gitTreeState=${GIT_TREE_STATE} \
-X github.com/devzero-inc/zxporter/internal/version.buildDate=${BUILD_DATE} \
-X github.com/devzero-inc/zxporter/internal/version.goVersion=${GO_VERSION}" \
-a -o zxporter-netmon cmd/zxporter-netmon/main.go
🤖 Prompt for AI Agents
In `@Dockerfile.netmon` around lines 32 - 40, The GO_VERSION is empty because
${GO_VERSION} is expanded by the shell before the inline assignment; fix by
computing GO_VERSION in the same shell session before running go build (e.g.,
run GO_VERSION=$(go version | awk '{print $3}') && then run CGO_ENABLED=0 ... go
build ...) so that the -ldflags value for
github.com/devzero-inc/zxporter/internal/version.goVersion uses the populated
GO_VERSION; update the RUN that invokes go build (referencing GO_VERSION, go
build, and the ldflags key version.goVersion) to perform the assignment first in
the same RUN command.

@Tzvonimir Tzvonimir merged commit 878f3f5 into main Jan 20, 2026
26 checks passed
@Tzvonimir Tzvonimir deleted the tzvonimir/network-operator-version branch January 20, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants