Skip to content

Commit 10cdedf

Browse files
craig[bot]railpav-kv
committed
148443: make and publish: tag staging repo early in process r=celiala a=rail Currently, the “Make and Publish Build” process creates a staging tag and pushes it to the staging repository only after all builds and tests have been completed. This approach delays the initiation of the “Build and Sign Cockroach Release” build. In optimal scenarios, “Make and Publish Build” can take over 30 minutes to finish, and any flaky tests can reset this timer. In urgent situations where fixes need to be deployed quickly, we want to initiate the release process without waiting for “Make and Publish Build” to complete. It’s important to note that the built binaries are merely staged and not published at this stage. To enhance efficiency, we can shift the tagging process to the beginning of the “Make and Publish Build.” This adjustment will allow us to commence building release binaries without being hindered by the blocking build jobs. Furthermore, we should publish the metadata.json file immediately after tagging to avoid delaying the Pick SHA process. Release note: none Fixes: RE-958 151317: kvserver: deflake BenchmarkBumpSideTransportClosed r=iskettaneh a=pav-kv Fixes #151295 Co-authored-by: Rail Aliiev <[email protected]> Co-authored-by: Pavel Kalinnikov <[email protected]>
3 parents a8886b4 + cdb9e86 + 3930324 commit 10cdedf

File tree

3 files changed

+63
-29
lines changed

3 files changed

+63
-29
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2022 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 -euo pipefail
10+
11+
# This script can be skipped for dry run and customized builds.
12+
is_customized_build="$(echo "$TC_BUILD_BRANCH" | grep -Eo "^custombuild-" || echo "")"
13+
if [[ -n "${DRY_RUN:-}" ]] || [[ -n "${is_customized_build}" ]]; then
14+
echo "Skipping for dry run or customized build."
15+
exit 0
16+
fi
17+
18+
dir="$(dirname $(dirname $(dirname $(dirname $(dirname "${0}")))))"
19+
source "$dir/release/teamcity-support.sh"
20+
21+
github_ssh_key="${GITHUB_COCKROACH_TEAMCITY_PRIVATE_SSH_KEY:?GITHUB_COCKROACH_TEAMCITY_PRIVATE_SSH_KEY must be specified}"
22+
metadata_gcs_bucket="cockroach-release-qualification-prod"
23+
metadata_google_credentials="$GCS_CREDENTIALS_PROD"
24+
build_name="$(git describe --tags --dirty --match=v[0-9]* 2> /dev/null || git rev-parse --short HEAD;)"
25+
26+
configure_git_ssh_key
27+
git tag "${build_name}"
28+
git_wrapped push ssh://[email protected]/cockroachlabs/release-staging.git "${build_name}"
29+
30+
# Publish build metadata to a stable location.
31+
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
32+
metadata_file="artifacts/metadata.json"
33+
mkdir -p artifacts
34+
cat > "$metadata_file" << EOF
35+
{
36+
"sha": "$BUILD_VCS_NUMBER",
37+
"timestamp": "$timestamp",
38+
"tag": "$build_name"
39+
}
40+
EOF
41+
# Run jq to pretty print and validate JSON
42+
jq . "$metadata_file"
43+
google_credentials=$metadata_google_credentials log_into_gcloud
44+
gsutil cp "$metadata_file" "gs://$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"
45+
echo "Published to https://storage.googleapis.com/$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"

build/teamcity/internal/release/process/make-and-publish-build-tagging.sh renamed to build/teamcity/internal/release/process/make-and-publish-build.sh

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ tc_end_block "Variable Setup"
7272
configure_git_ssh_key
7373

7474
if [[ -z "${is_customized_build}" ]] ; then
75-
tc_start_block "Tag the release"
76-
git tag "${build_name}"
77-
tc_end_block "Tag the release"
78-
79-
tc_start_block "Push release tag to github.com/cockroachlabs/release-staging"
80-
git_wrapped push ssh://[email protected]/cockroachlabs/release-staging.git "${build_name}"
81-
tc_end_block "Push release tag to github.com/cockroachlabs/release-staging"
82-
83-
8475
tc_start_block "Tag docker image as latest-build"
8576
# Only tag the image as "latest-vX.Y-build" if the tag is on a release branch
8677
# (or master for the alphas for the next major release).
@@ -120,22 +111,3 @@ if [[ -n "${is_customized_build}" ]] ; then
120111
git_wrapped push ssh://[email protected]/cockroachdb/cockroach.git --delete "${TC_BUILD_BRANCH}"
121112
tc_end_block "Delete custombuild tag"
122113
fi
123-
124-
# Publish build metadata to a stable location.
125-
tc_start_block "Metadata"
126-
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
127-
metadata_file="artifacts/metadata.json"
128-
mkdir -p artifacts
129-
cat > "$metadata_file" << EOF
130-
{
131-
"sha": "$BUILD_VCS_NUMBER",
132-
"timestamp": "$timestamp",
133-
"tag": "$build_name"
134-
}
135-
EOF
136-
# Run jq to pretty print and validate JSON
137-
jq . "$metadata_file"
138-
google_credentials=$metadata_google_credentials log_into_gcloud
139-
gsutil cp "$metadata_file" "gs://$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"
140-
echo "Published to https://storage.googleapis.com/$metadata_gcs_bucket/builds/$BUILD_VCS_NUMBER.json"
141-
tc_end_block "Metadata"

pkg/kv/kvserver/replica_closedts_test.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,7 @@ func TestRejectedLeaseDoesntDictateClosedTimestamp(t *testing.T) {
694694
// we eliminate some memory copying and pass the node liveness record in to the
695695
// function so that we only have to grab it once instead of on each call to
696696
// BumpSideTransportClosed, we should be able to reach our target latency.
697+
// TODO(pav-kv): in 2025, this shows about 180-200ns.
697698
func BenchmarkBumpSideTransportClosed(b *testing.B) {
698699
defer leaktest.AfterTest(b)()
699700
defer log.Scope(b).Close(b)
@@ -721,6 +722,22 @@ func BenchmarkBumpSideTransportClosed(b *testing.B) {
721722
now := s.Clock().NowAsClockTimestamp()
722723
targets := map[ctpb.RangeClosedTimestampPolicy]hlc.Timestamp{}
723724

725+
// Wait for the scratch range's lease upgrade from expiration-based lease. The
726+
// closed timestamp bumping requires for there to be no in-flight proposals,
727+
// so a racing lease upgrade can cause a test failure like in #151295.
728+
//
729+
// TODO(pav-kv): share this code with TestCluster.MaybeWaitForLeaseUpgrade().
730+
testutils.SucceedsSoon(b, func() error {
731+
lease, _, err := s.GetRangeLease(ctx, key, roachpb.QueryLocalNodeOnly)
732+
require.NoError(b, err)
733+
typ := lease.Current().Type()
734+
if typ == roachpb.LeaseExpiration {
735+
return errors.Errorf("still on expiration-based lease")
736+
}
737+
b.Logf("lease is now of type: %s", typ)
738+
return nil
739+
})
740+
724741
b.ResetTimer()
725742
for i := 0; i < b.N; i++ {
726743
// Advance time and the closed timestamp target.
@@ -730,7 +747,7 @@ func BenchmarkBumpSideTransportClosed(b *testing.B) {
730747
// Perform the call.
731748
res := r.BumpSideTransportClosed(ctx, now, targets)
732749
if !res.OK {
733-
b.Fatal("BumpSideTransportClosed unexpectedly failed")
750+
b.Fatalf("BumpSideTransportClosed unexpectedly failed: %+v", res)
734751
}
735752
}
736753
}

0 commit comments

Comments
 (0)