Skip to content

Commit 0d64be6

Browse files
authored
Merge pull request #151866 from rail/backport24.3-146755-147973
2 parents 0cbf86b + 14c647f commit 0d64be6

25 files changed

+701
-228
lines changed

.bazelrc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,32 +92,32 @@ build:cross --stamp
9292
# `--workspace_status_command`; if using these `base` configs, you need to
9393
# specify an appropriate `--workspace_status_command`. These `base` configs are
9494
# used by the release process which needs to have more control over stamping.
95-
build:crosslinux '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-pc-linux-gnu'
95+
build:crosslinux '--workspace_status_command=./build/bazelutil/stamp.sh -t x86_64-pc-linux-gnu'
9696
build:crosslinux --config=crosslinuxbase
9797
build:crosslinuxbase --platforms=//build/toolchains:cross_linux
9898
build:crosslinuxbase --config=cross
99-
build:crosslinuxfips '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-pc-linux-gnu'
99+
build:crosslinuxfips '--workspace_status_command=./build/bazelutil/stamp.sh -t x86_64-pc-linux-gnu'
100100
build:crosslinuxfips --config=crosslinuxfipsbase
101101
build:crosslinuxfipsbase --platforms=//build/toolchains:cross_linux
102102
build:crosslinuxfipsbase --config=cross
103103
build:crosslinuxfipsbase --@io_bazel_rules_go//go/toolchain:sdk_version=1.22.12fips
104-
build:crosswindows '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-w64-mingw32'
104+
build:crosswindows '--workspace_status_command=./build/bazelutil/stamp.sh -t x86_64-w64-mingw32'
105105
build:crosswindows --config=crosswindowsbase
106106
build:crosswindowsbase --platforms=//build/toolchains:cross_windows
107107
build:crosswindowsbase --config=cross
108-
build:crossmacos '--workspace_status_command=./build/bazelutil/stamp.sh x86_64-apple-darwin21.2'
108+
build:crossmacos '--workspace_status_command=./build/bazelutil/stamp.sh -t x86_64-apple-darwin21.2'
109109
build:crossmacos --config=crossmacosbase
110110
build:crossmacosbase --platforms=//build/toolchains:cross_macos
111111
build:crossmacosbase --config=cross
112-
build:crossmacosarm '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-apple-darwin21.2'
112+
build:crossmacosarm '--workspace_status_command=./build/bazelutil/stamp.sh -t aarch64-apple-darwin21.2'
113113
build:crossmacosarm --config=crossmacosarmbase
114114
build:crossmacosarmbase --platforms=//build/toolchains:cross_macos_arm
115115
build:crossmacosarmbase --config=cross
116-
build:crosslinuxarm '--workspace_status_command=./build/bazelutil/stamp.sh aarch64-unknown-linux-gnu'
116+
build:crosslinuxarm '--workspace_status_command=./build/bazelutil/stamp.sh -t aarch64-unknown-linux-gnu'
117117
build:crosslinuxarm --config=crosslinuxarmbase
118118
build:crosslinuxarmbase --platforms=//build/toolchains:cross_linux_arm
119119
build:crosslinuxarmbase --config=cross
120-
build:crosslinuxs390x '--workspace_status_command=./build/bazelutil/stamp.sh s390x-unknown-linux-gnu'
120+
build:crosslinuxs390x '--workspace_status_command=./build/bazelutil/stamp.sh -t s390x-unknown-linux-gnu'
121121
build:crosslinuxs390x --config=crosslinuxs390xbase
122122
build:crosslinuxs390xbase --platforms=//build/toolchains:cross_linux_s390x
123123
build:crosslinuxs390xbase --config=cross

build/bazelutil/stamp.sh

Lines changed: 35 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@
99
# This command is used by bazel as the workspace_status_command
1010
# to implement build stamping with git information.
1111

12-
# Usage: stamp.sh [target-triple] [build-channel] [build-type]
12+
# Usage: stamp.sh [-t target-triple] [-c build-channel] [-b build-type] [-g build-tag] [-d telemetry-disabled]
1313
# All arguments are optional and have appropriate defaults. In this way,
1414
# stamp.sh with no arguments is appropriate as the `workplace_status_command`
1515
# for a development build.
16-
# target-triple: defaults to the value of `cc -dumpmachine`
17-
# build-channel: defaults to `unknown`, but can be `official-binary`
18-
# build-type: defaults to `development`, but can be `release`
19-
# build-tag: will default to an appropriate value if not passed in, but can be overridden
16+
# -t target-triple: defaults to the value of `cc -dumpmachine`
17+
# -c build-channel: defaults to `unknown`, but can be `official-binary`
18+
# -b build-type: defaults to `development`, but can be `release`
19+
# -g build-tag: will default to an appropriate value if not passed in, but can be overridden
20+
# -d telemetry-disabled: defaults to `false`, but can be set to `true`.
2021

2122
set -euo pipefail
2223

@@ -29,56 +30,38 @@ set -euo pipefail
2930
# For details, see the "Possible timestamp problems with diff-files?" thread on
3031
# the Git mailing list (http://marc.info/?l=git&m=131687596307197).
3132

32-
# Handle target-triple.
33-
if [ -z "${1+x}" ]
34-
then
35-
TARGET_TRIPLE=$(cc -dumpmachine)
36-
else
37-
TARGET_TRIPLE="$1"
38-
shift 1
39-
fi
33+
# Default values
34+
TARGET_TRIPLE="$(cc -dumpmachine)"
35+
BUILD_CHANNEL="unknown"
36+
BUILD_TYPE="development"
37+
BUILD_TAG=""
38+
TELEMETRY_DISABLED=false
4039

41-
# Handle build-channel.
42-
if [ -z "${1+x}" ]
43-
then
44-
BUILD_CHANNEL="unknown"
45-
else
46-
BUILD_CHANNEL="$1"
47-
shift 1
48-
fi
49-
50-
# Handle build-type.
51-
if [ -z "${1+x}" ]
52-
then
53-
BUILD_TYPE="development"
54-
else
55-
BUILD_TYPE="$1"
56-
shift 1
57-
fi
40+
# Parse command line arguments
41+
while getopts "t:c:b:g:d:" opt; do
42+
case $opt in
43+
t) TARGET_TRIPLE="$OPTARG" ;;
44+
c) BUILD_CHANNEL="$OPTARG" ;;
45+
b) BUILD_TYPE="$OPTARG" ;;
46+
g) BUILD_TAG="$OPTARG" ;;
47+
d) TELEMETRY_DISABLED="$OPTARG" ;;
48+
\?) echo "Invalid option -$OPTARG" >&2; exit 1 ;;
49+
esac
50+
done
5851

5952
if [ "$BUILD_TYPE" = "release" ]
6053
then
61-
CRASH_REPORT_ENV=$(cat ./pkg/build/version.txt)
54+
CRASH_REPORT_ENV="$(cat ./pkg/build/version.txt)"
6255
else
6356
CRASH_REPORT_ENV="development"
6457
fi
6558

66-
# Handle build-tag.
67-
if [ -z "${1+x}" ]
68-
then
69-
BUILD_TAG=
70-
else
71-
BUILD_TAG="$1"
72-
shift 1
73-
fi
74-
75-
BUILD_REV=$(git describe --match="" --always --abbrev=40)
59+
BUILD_REV="$(git describe --match="" --always --abbrev=40)"
7660
if [[ -n "$(git status -s --ignore-submodules --untracked-files=no)" ]]; then
77-
BUILD_REV=$BUILD_REV-dirty
61+
BUILD_REV="$BUILD_REV-dirty"
7862
fi
7963

80-
BUILD_UTCTIME=$(date -u '+%Y/%m/%d %H:%M:%S')
81-
64+
BUILD_UTCTIME="$(date -u '+%Y/%m/%d %H:%M:%S')"
8265

8366
# Variables beginning with "STABLE" will be written to stable-status.txt, and
8467
# others will be written to volatile-status.txt.
@@ -88,11 +71,12 @@ BUILD_UTCTIME=$(date -u '+%Y/%m/%d %H:%M:%S')
8871
# * https://docs.bazel.build/versions/main/user-manual.html#workspace_status
8972
# * https://github.com/bazelbuild/rules_go/blob/master/go/core.rst#defines-and-stamping
9073
cat <<EOF
91-
STABLE_BUILD_CHANNEL ${BUILD_CHANNEL-}
92-
STABLE_BUILD_TAG ${BUILD_TAG-}
93-
STABLE_BUILD_TARGET_TRIPLE ${TARGET_TRIPLE-}
94-
STABLE_BUILD_TYPE ${BUILD_TYPE-}
95-
STABLE_CRASH_REPORT_ENV ${CRASH_REPORT_ENV-}
96-
BUILD_REV ${BUILD_REV-}
97-
BUILD_UTCTIME ${BUILD_UTCTIME-}
74+
STABLE_BUILD_CHANNEL $BUILD_CHANNEL
75+
STABLE_BUILD_TAG $BUILD_TAG
76+
STABLE_BUILD_TARGET_TRIPLE $TARGET_TRIPLE
77+
STABLE_BUILD_TYPE $BUILD_TYPE
78+
STABLE_CRASH_REPORT_ENV $CRASH_REPORT_ENV
79+
STABLE_TELEMETRY_DISABLED $TELEMETRY_DISABLED
80+
BUILD_REV $BUILD_REV
81+
BUILD_UTCTIME $BUILD_UTCTIME
9882
EOF

build/release/teamcity-support.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ verify_docker_image(){
6666
local expected_sha=$3
6767
local expected_build_tag=$4
6868
local fips_build=$5
69+
local telemetry_disabled=$6
6970
local error=0
7071

7172
docker rmi "$img" || true
@@ -107,6 +108,18 @@ verify_docker_image(){
107108
error=1
108109
fi
109110
fi
111+
if [[ $docker_platform == "linux/amd64" ]]; then
112+
# Running arm64 `cockroach demo` on amd64 times out.
113+
telemetry_setting="$(docker run -t --platform="$docker_platform" "$img" demo --no-example-database -e 'SHOW CLUSTER SETTING diagnostics.reporting.enabled;' --format json | grep "diagnostics.reporting.enabled" | cut -d: -f2 | cut -d'"' -f2)"
114+
if [[ $telemetry_disabled == true && $telemetry_setting != "f" ]]; then
115+
echo "ERROR: expected telemetry to be disabled, but it is enabled"
116+
error=1
117+
fi
118+
if [[ $telemetry_disabled == false && $telemetry_setting != "t" ]]; then
119+
echo "ERROR: expected telemetry to be enabled, but it is disabled"
120+
error=1
121+
fi
122+
fi
110123
return $error
111124
}
112125

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The Cockroach Authors.
4+
#
5+
# Use of this software is governed by the CockroachDB Software License
6+
# included in the /LICENSE file.
7+
8+
9+
set -euxo pipefail
10+
11+
dir="$(dirname $(dirname $(dirname $(dirname $(dirname $(dirname "${0}"))))))"
12+
source "$dir/teamcity-support.sh" # For log_into_gcloud
13+
14+
tc_start_block "Variable Setup"
15+
version=$(grep -v "^#" "$dir/../pkg/build/version.txt" | head -n1)
16+
cockroach_archive_prefix="${COCKROACH_ARCHIVE_PREFIX:?COCKROACH_ARCHIVE_PREFIX must be set and not set to 'cockroach'}"
17+
if [[ $cockroach_archive_prefix == "cockroach" ]]; then
18+
echo "COCKROACH_ARCHIVE_PREFIX must be set to a non-default value"
19+
exit 1
20+
fi
21+
22+
if [[ -z "${DRY_RUN}" ]] ; then
23+
# TODO: use different buckets here maybe?
24+
gcs_bucket="cockroach-release-artifacts-prod"
25+
gcs_staged_bucket="cockroach-release-artifacts-staged-prod"
26+
# export the variable to avoid shell escaping
27+
export gcs_credentials="$GCS_CREDENTIALS_PROD"
28+
else
29+
gcs_bucket="cockroach-release-artifacts-dryrun"
30+
gcs_staged_bucket="cockroach-release-artifacts-staged-dryrun"
31+
# export the variable to avoid shell escaping
32+
export gcs_credentials="$GCS_CREDENTIALS_DEV"
33+
fi
34+
tc_end_block "Variable Setup"
35+
36+
37+
tc_start_block "Copy binaries"
38+
log_into_gcloud
39+
for platform in linux-amd64 linux-arm64; do
40+
archive="${cockroach_archive_prefix}-${version}.${platform}.tgz"
41+
gsutil cp "gs://$gcs_staged_bucket/$archive" "gs://$gcs_bucket/$archive"
42+
gsutil cp "gs://$gcs_staged_bucket/$archive.sha256sum" "gs://$gcs_bucket/$archive.sha256sum"
43+
done
44+
tc_end_block "Copy binaries"

build/teamcity/internal/cockroach/release/publish/publish-staged-cockroach-release.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ tc_start_block "Verify binaries SHA"
7171
# Make sure that the linux/amd64 source docker image is built using the same version and SHA.
7272
# This is a quick check and it assumes that the docker image was built correctly and based on the tarball binaries.
7373
docker_login_gcr "$gcr_staged_repository" "$gcr_staged_credentials"
74-
verify_docker_image "${gcr_staged_repository}:${version}" "linux/amd64" "$BUILD_VCS_NUMBER" "$version" false
74+
verify_docker_image "${gcr_staged_repository}:${version}" "linux/amd64" "$BUILD_VCS_NUMBER" "$version" false false
7575
tc_end_block "Verify binaries SHA"
7676

7777
tc_start_block "Check remote tag and tag"
@@ -242,7 +242,7 @@ fi
242242
for img in "${images[@]}"; do
243243
for platform_name in amd64 arm64; do
244244
tc_start_block "Verify $img on $platform_name"
245-
if ! verify_docker_image "$img" "linux/$platform_name" "$BUILD_VCS_NUMBER" "$version" false; then
245+
if ! verify_docker_image "$img" "linux/$platform_name" "$BUILD_VCS_NUMBER" "$version" false false; then
246246
error=1
247247
fi
248248
tc_end_block "Verify $img on $platform_name"
@@ -252,7 +252,7 @@ done
252252
images=("${dockerhub_tag_fips}" "${gcr_tag_fips}")
253253
for img in "${images[@]}"; do
254254
tc_start_block "Verify $img"
255-
if ! verify_docker_image "$img" "linux/amd64" "$BUILD_VCS_NUMBER" "$version" true; then
255+
if ! verify_docker_image "$img" "linux/amd64" "$BUILD_VCS_NUMBER" "$version" true false; then
256256
error=1
257257
fi
258258
tc_end_block "Verify $img"

build/teamcity/internal/release/process/build-cockroach-release-cloud-only.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ tc_start_block "Verify docker images"
7979
error=0
8080
for arch in amd64 arm64; do
8181
tc_start_block "Verify $manifest on $arch"
82-
if ! verify_docker_image "$manifest" "linux/$arch" "$BUILD_VCS_NUMBER" "$version" false; then
82+
if ! verify_docker_image "$manifest" "linux/$arch" "$BUILD_VCS_NUMBER" "$version" false false; then
8383
error=1
8484
fi
8585
tc_end_block "Verify $manifest on $arch"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2023 The Cockroach Authors.
4+
#
5+
# Use of this software is governed by the CockroachDB Software License
6+
# included in the /LICENSE file.
7+
8+
9+
TELEMETRY_DISABLED=true ./build/teamcity/internal/release/process/build-cockroach-release-docker.sh

build/teamcity/internal/release/process/build-cockroach-release-docker.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))"
1212
source "$dir/release/teamcity-support.sh"
1313

1414
tc_start_block "Variable Setup"
15+
telemetry_disabled="${TELEMETRY_DISABLED:-false}"
16+
cockroach_archive_prefix="${COCKROACH_ARCHIVE_PREFIX:-cockroach}"
17+
if [[ $telemetry_disabled == true && $cockroach_archive_prefix == "cockroach" ]]; then
18+
echo "COCKROACH_ARCHIVE_PREFIX must be set to a non-default value when telemetry is disabled"
19+
exit 1
20+
fi
21+
1522
version=$(grep -v "^#" "$dir/../pkg/build/version.txt" | head -n1)
1623
if [[ -z "${DRY_RUN}" ]] ; then
1724
gcr_credentials="$GCS_CREDENTIALS_PROD"
18-
gcr_staged_repository="us-docker.pkg.dev/releases-prod/cockroachdb-staged-releases/cockroach"
25+
gcr_staged_repository="us-docker.pkg.dev/releases-prod/cockroachdb-staged-releases/${cockroach_archive_prefix}"
1926
else
2027
gcr_credentials="$GCS_CREDENTIALS_DEV"
21-
gcr_staged_repository="us-docker.pkg.dev/releases-dev-356314/cockroachdb-staged-releases/cockroach"
28+
gcr_staged_repository="us-docker.pkg.dev/releases-dev-356314/cockroachdb-staged-releases/${cockroach_archive_prefix}"
2229
fi
2330
tc_end_block "Variable Setup"
2431

@@ -33,7 +40,7 @@ tc_start_block "Verify docker images"
3340
error=0
3441
for arch in amd64 arm64; do
3542
tc_start_block "Verify $gcr_tag on $arch"
36-
if ! verify_docker_image "$gcr_tag" "linux/$arch" "$BUILD_VCS_NUMBER" "$version" false; then
43+
if ! verify_docker_image "$gcr_tag" "linux/$arch" "$BUILD_VCS_NUMBER" "$version" false "$telemetry_disabled"; then
3744
error=1
3845
fi
3946
tc_end_block "Verify $gcr_tag on $arch"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 The Cockroach Authors.
4+
#
5+
# Use of this software is governed by the CockroachDB Software License
6+
# included in the /LICENSE file.
7+
8+
9+
PLATFORM=linux-amd64 TELEMETRY_DISABLED=true ./build/teamcity/internal/release/process/build-cockroach-release-per-platform.sh
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2025 The Cockroach Authors.
4+
#
5+
# Use of this software is governed by the CockroachDB Software License
6+
# included in the /LICENSE file.
7+
8+
9+
PLATFORM=linux-arm64 TELEMETRY_DISABLED=true ./build/teamcity/internal/release/process/build-cockroach-release-per-platform.sh

0 commit comments

Comments
 (0)