From 66a13e63252eb87ccd312d00eec1d44f2ca89e97 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 19:27:33 +0000 Subject: [PATCH 1/4] Initial plan From f5bdcb9b983432b34c33e2e7ef88ad5b640e724d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 19:37:53 +0000 Subject: [PATCH 2/4] Implement v2 default for build targets (Milestone 1) - Update BuildBinaries.mk to default JAEGER_VERSION=2 for most targets - Keep four exception targets as v1: build-all-in-one, build-query, build-collector, build-ingester - Update build-upload-a-docker-image.sh to default JAEGER_VERSION=2 - Update compute-tags.sh with v2-first documentation - Add header comments explaining override mechanism Co-authored-by: yurishkuro <3523016+yurishkuro@users.noreply.github.com> --- scripts/build/build-upload-a-docker-image.sh | 10 +++++- scripts/makefiles/BuildBinaries.mk | 35 +++++++++++++++----- scripts/utils/compute-tags.sh | 8 +++++ 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/scripts/build/build-upload-a-docker-image.sh b/scripts/build/build-upload-a-docker-image.sh index cca98f88d76..8cc2c6f9658 100755 --- a/scripts/build/build-upload-a-docker-image.sh +++ b/scripts/build/build-upload-a-docker-image.sh @@ -3,8 +3,16 @@ # Copyright (c) 2024 The Jaeger Authors. # SPDX-License-Identifier: Apache-2.0 +# This script builds and optionally uploads a Docker image. +# Default behavior changed: now produces v2 artifacts unless JAEGER_VERSION=1 is explicitly set. +# To build v1 artifacts: JAEGER_VERSION=1 ./build-upload-a-docker-image.sh ... +# To build v2 artifacts (default): ./build-upload-a-docker-image.sh ... or JAEGER_VERSION=2 ... + set -euf -o pipefail +# Default to v2 unless explicitly overridden +JAEGER_VERSION=${JAEGER_VERSION:-2} + print_help() { echo "Usage: $0 [-c] [-D] [-h] [-l] [-o] [-p platforms]" echo "-h: Print help" @@ -96,7 +104,7 @@ if [[ "${local_test_only}" = "Y" ]]; then else echo "::group:: compute tags ${component_name}" # shellcheck disable=SC2086 - IFS=" " read -r -a IMAGE_TAGS <<< "$(bash scripts/utils/compute-tags.sh ${namespace}/${component_name})" + IFS=" " read -r -a IMAGE_TAGS <<< "$(JAEGER_VERSION=${JAEGER_VERSION} bash scripts/utils/compute-tags.sh ${namespace}/${component_name})" echo "::endgroup::" # Only push multi-arch images to dockerhub/quay.io for main branch or for release tags vM.N.P{-rcX} diff --git a/scripts/makefiles/BuildBinaries.mk b/scripts/makefiles/BuildBinaries.mk index 876aed4681d..556ebd4ba41 100644 --- a/scripts/makefiles/BuildBinaries.mk +++ b/scripts/makefiles/BuildBinaries.mk @@ -1,10 +1,29 @@ # Copyright (c) 2023 The Jaeger Authors. # SPDX-License-Identifier: Apache-2.0 +# JAEGER_VERSION controls which version of build info is embedded in binaries. +# Default is v2 (JAEGER_VERSION=2), except for four legacy targets that remain v1: +# - build-all-in-one +# - build-query +# - build-collector +# - build-ingester +# To explicitly build v1 artifacts for other targets, set JAEGER_VERSION=1 when invoking make. +# Example: JAEGER_VERSION=1 make build-jaeger + # This command expects $GOOS/$GOARCH env variables set to reflect the desired target platform. GOBUILD=echo "building binary for $$(go env GOOS)-$$(go env GOARCH)"; \ CGO_ENABLED=0 installsuffix=cgo $(GO) build -trimpath +# Default JAEGER_VERSION to 2 unless building one of the four exception targets +# or JAEGER_VERSION is explicitly set by the caller +ifeq ($(JAEGER_VERSION),) + ifeq ($(filter $(MAKECMDGOALS),build-all-in-one build-query build-collector build-ingester),) + JAEGER_VERSION := 2 + else + JAEGER_VERSION := 1 + endif +endif + ifeq ($(DEBUG_BINARY),) DISABLE_OPTIMIZATIONS = SUFFIX = @@ -43,34 +62,34 @@ build-examples: .PHONY: build-tracegen build-tracegen: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/tracegen/tracegen-$(GOOS)-$(GOARCH) ./cmd/tracegen/ + $(GOBUILD) $(BUILD_INFO_V$(JAEGER_VERSION)) -o ./cmd/tracegen/tracegen-$(GOOS)-$(GOARCH) ./cmd/tracegen/ .PHONY: build-anonymizer build-anonymizer: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/anonymizer/anonymizer-$(GOOS)-$(GOARCH) ./cmd/anonymizer/ + $(GOBUILD) $(BUILD_INFO_V$(JAEGER_VERSION)) -o ./cmd/anonymizer/anonymizer-$(GOOS)-$(GOARCH) ./cmd/anonymizer/ .PHONY: build-esmapping-generator build-esmapping-generator: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/esmapping-generator/esmapping-generator-$(GOOS)-$(GOARCH) ./cmd/esmapping-generator/ + $(GOBUILD) $(BUILD_INFO_V$(JAEGER_VERSION)) -o ./cmd/esmapping-generator/esmapping-generator-$(GOOS)-$(GOARCH) ./cmd/esmapping-generator/ .PHONY: build-es-index-cleaner build-es-index-cleaner: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/es-index-cleaner/es-index-cleaner-$(GOOS)-$(GOARCH) ./cmd/es-index-cleaner/ + $(GOBUILD) $(BUILD_INFO_V$(JAEGER_VERSION)) -o ./cmd/es-index-cleaner/es-index-cleaner-$(GOOS)-$(GOARCH) ./cmd/es-index-cleaner/ .PHONY: build-es-rollover build-es-rollover: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/es-rollover/es-rollover-$(GOOS)-$(GOARCH) ./cmd/es-rollover/ + $(GOBUILD) $(BUILD_INFO_V$(JAEGER_VERSION)) -o ./cmd/es-rollover/es-rollover-$(GOOS)-$(GOARCH) ./cmd/es-rollover/ -# Requires variables: $(BIN_NAME) $(BIN_PATH) $(GO_TAGS) $(DISABLE_OPTIMIZATIONS) $(SUFFIX) $(GOOS) $(GOARCH) $(BUILD_INFO) +# Requires variables: $(BIN_NAME) $(BIN_PATH) $(GO_TAGS) $(DISABLE_OPTIMIZATIONS) $(SUFFIX) $(GOOS) $(GOARCH) # Other targets can depend on this one but with a unique suffix to ensure it is always executed. +# BUILD_INFO is selected based on JAEGER_VERSION (v1 or v2). BIN_PATH = ./cmd/$(BIN_NAME) .PHONY: _build-a-binary _build-a-binary-%: - $(GOBUILD) $(DISABLE_OPTIMIZATIONS) $(GO_TAGS) -o $(BIN_PATH)/$(BIN_NAME)$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) $(BIN_PATH) + $(GOBUILD) $(DISABLE_OPTIMIZATIONS) $(GO_TAGS) -o $(BIN_PATH)/$(BIN_NAME)$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO_V$(JAEGER_VERSION)) $(BIN_PATH) .PHONY: build-jaeger build-jaeger: BIN_NAME = jaeger -build-jaeger: BUILD_INFO = $(BUILD_INFO_V2) build-jaeger: build-ui _build-a-binary-jaeger$(SUFFIX)-$(GOOS)-$(GOARCH) @ set -euf -o pipefail ; \ echo "Checking version of built binary" ; \ diff --git a/scripts/utils/compute-tags.sh b/scripts/utils/compute-tags.sh index 7d0e296436f..e4e521348f2 100755 --- a/scripts/utils/compute-tags.sh +++ b/scripts/utils/compute-tags.sh @@ -4,6 +4,13 @@ # SPDX-License-Identifier: Apache-2.0 # Compute major/minor/etc image tags based on the current branch +# +# Default behavior changed: produces v2-first tags unless JAEGER_VERSION=1 is explicitly set. +# To generate v1-only tags: JAEGER_VERSION=1 ./compute-tags.sh +# To generate v2-first tags (default): ./compute-tags.sh or JAEGER_VERSION=2 ... +# +# When JAEGER_VERSION=2 (or unset), v2 tags are produced first. +# When JAEGER_VERSION=1, v1 tags are produced. set -ef -o pipefail @@ -16,6 +23,7 @@ set -u BASE_BUILD_IMAGE=${1:?'expecting Docker image name as argument, such as jaegertracing/jaeger'} BRANCH=${BRANCH:?'expecting BRANCH env var'} GITHUB_SHA=${GITHUB_SHA:-$(git rev-parse HEAD)} +JAEGER_VERSION=${JAEGER_VERSION:-2} # accumulate output in this variable IMAGE_TAGS="" From 3cd62e13b480de86fd7fd6f84203d7a68f13116c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 19:44:25 +0000 Subject: [PATCH 3/4] Add BUILD_INFO_V1 definition to fix v1 target builds The BUILD_INFO_V1 variable was not explicitly defined, causing v1 exception targets to build without version info. This fix ensures both BUILD_INFO_V1 and BUILD_INFO_V2 are properly defined. Co-authored-by: yurishkuro <3523016+yurishkuro@users.noreply.github.com> --- scripts/makefiles/BuildInfo.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/makefiles/BuildInfo.mk b/scripts/makefiles/BuildInfo.mk index a60d37b15cb..0d0bfcd6b84 100644 --- a/scripts/makefiles/BuildInfo.mk +++ b/scripts/makefiles/BuildInfo.mk @@ -17,4 +17,5 @@ define buildinfoflags -ldflags "-X $(call buildinfo,commitSHA,$(GIT_SHA)) -X $(call buildinfo,latestVersion,$(GIT_CLOSEST_TAG_$(1))) -X $(call buildinfo,date,$(DATE))" endef BUILD_INFO=$(call buildinfoflags,V1) +BUILD_INFO_V1=$(call buildinfoflags,V1) BUILD_INFO_V2=$(call buildinfoflags,V2) From daaaecfc52686bb243d986cb222aad5b3f791b8e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 12 Nov 2025 19:47:55 +0000 Subject: [PATCH 4/4] Add comprehensive test script for v2 defaults Created test-v2-defaults.sh to verify: - v2 is default for non-exception targets - v1 is default for four exception targets - Override mechanism works correctly All 15 tests pass successfully. Co-authored-by: yurishkuro <3523016+yurishkuro@users.noreply.github.com> --- test-v2-defaults.sh | 129 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100755 test-v2-defaults.sh diff --git a/test-v2-defaults.sh b/test-v2-defaults.sh new file mode 100755 index 00000000000..52855ccf85f --- /dev/null +++ b/test-v2-defaults.sh @@ -0,0 +1,129 @@ +#!/bin/bash + +# Copyright (c) 2025 The Jaeger Authors. +# SPDX-License-Identifier: Apache-2.0 + +# Test script to verify Milestone 1: v2 default reassignment +# This script verifies that build targets default to v2 except for the four exception targets. + +set -uo pipefail + +cd "$(dirname "$0")" + +echo "Testing Milestone 1: v2 Default Reassignment" +echo "==============================================" +echo "" + +# Color codes for output +GREEN='\033[0;32m' +RED='\033[0;31m' +NC='\033[0m' # No Color + +pass_count=0 +fail_count=0 + +test_version() { + local target="$1" + local expected_version="$2" + local description="$3" + + echo -n "Testing $description... " + + # Run make with -n (dry-run) and grep for latestVersion + local actual_version + actual_version=$(make -n "$target" GOOS=linux GOARCH=amd64 2>&1 | grep -oP 'latestVersion=v\K[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true) + + if [ -z "$actual_version" ]; then + echo -e "${RED}FAIL${NC} (no version found)" + ((fail_count++)) + return 0 + fi + + local expected_major="${expected_version%%.*}" + local actual_major="${actual_version%%.*}" + + if [ "$actual_major" = "$expected_major" ]; then + echo -e "${GREEN}PASS${NC} (v$actual_version)" + ((pass_count++)) + else + echo -e "${RED}FAIL${NC} (expected v$expected_version, got v$actual_version)" + ((fail_count++)) + fi + return 0 +} + +test_override() { + local target="$1" + local override_version="$2" + local expected_version="$3" + local description="$4" + + echo -n "Testing $description... " + + # Run make with -n (dry-run) and grep for latestVersion + local actual_version + actual_version=$(JAEGER_VERSION="$override_version" make -n "$target" GOOS=linux GOARCH=amd64 2>&1 | grep -oP 'latestVersion=v\K[0-9]+\.[0-9]+\.[0-9]+' | head -1 || true) + + if [ -z "$actual_version" ]; then + echo -e "${RED}FAIL${NC} (no version found)" + ((fail_count++)) + return 0 + fi + + local expected_major="${expected_version%%.*}" + local actual_major="${actual_version%%.*}" + + if [ "$actual_major" = "$expected_major" ]; then + echo -e "${GREEN}PASS${NC} (v$actual_version)" + ((pass_count++)) + else + echo -e "${RED}FAIL${NC} (expected v$expected_version, got v$actual_version)" + ((fail_count++)) + fi + return 0 +} + +echo "1. Testing v2 defaults for non-exception targets:" +echo "--------------------------------------------------" +test_version "build-jaeger" "2" "build-jaeger defaults to v2" +test_version "build-tracegen" "2" "build-tracegen defaults to v2" +test_version "build-anonymizer" "2" "build-anonymizer defaults to v2" +test_version "build-esmapping-generator" "2" "build-esmapping-generator defaults to v2" +test_version "build-es-index-cleaner" "2" "build-es-index-cleaner defaults to v2" +test_version "build-es-rollover" "2" "build-es-rollover defaults to v2" +test_version "build-remote-storage" "2" "build-remote-storage defaults to v2" +echo "" + +echo "2. Testing v1 defaults for exception targets:" +echo "----------------------------------------------" +test_version "build-all-in-one" "1" "build-all-in-one defaults to v1" +test_version "build-query" "1" "build-query defaults to v1" +test_version "build-collector" "1" "build-collector defaults to v1" +test_version "build-ingester" "1" "build-ingester defaults to v1" +echo "" + +echo "3. Testing override mechanism (v2 targets to v1):" +echo "--------------------------------------------------" +test_override "build-jaeger" "1" "1" "JAEGER_VERSION=1 build-jaeger uses v1" +test_override "build-tracegen" "1" "1" "JAEGER_VERSION=1 build-tracegen uses v1" +echo "" + +echo "4. Testing override mechanism (v1 targets to v2):" +echo "--------------------------------------------------" +test_override "build-all-in-one" "2" "2" "JAEGER_VERSION=2 build-all-in-one uses v2" +test_override "build-collector" "2" "2" "JAEGER_VERSION=2 build-collector uses v2" +echo "" + +echo "==============================================" +echo "Test Results:" +echo " Passed: $pass_count" +echo " Failed: $fail_count" +echo "==============================================" + +if [ "$fail_count" -eq 0 ]; then + echo -e "${GREEN}All tests passed!${NC}" + exit 0 +else + echo -e "${RED}Some tests failed!${NC}" + exit 1 +fi