SERVER-120949: Remove Tag Based FCV Generation (#49061)

GitOrigin-RevId: 71d11d29d6e9077edbedf4a95bc6b1977666d358
This commit is contained in:
Zack Winter 2026-04-28 16:20:06 -07:00 committed by MongoDB Bot
parent 8f676e69ab
commit aef13e0584
12 changed files with 84 additions and 52 deletions

View File

@ -660,9 +660,6 @@ try-import %workspace%/.bazelrc.common_bes
# Settings unconditionally written by the wrapper hook # Settings unconditionally written by the wrapper hook
try-import %workspace%/.bazelrc.wrapper_hook try-import %workspace%/.bazelrc.wrapper_hook
# local git version info
try-import %workspace%/.bazelrc.git
# Used for build profiles and any settings a user wants to consistently use # Used for build profiles and any settings a user wants to consistently use
try-import %workspace%/.bazelrc.local try-import %workspace%/.bazelrc.local
@ -678,6 +675,12 @@ try-import %workspace%/.bazelrc.engflow_creds
# Flags for fuzztest # Flags for fuzztest
try-import %workspace%/.bazelrc.fuzztest try-import %workspace%/.bazelrc.fuzztest
# Default mongo version
try-import %workspace%/.bazelrc.target_mongo_version
# local git version info (after target_mongo_version so its MONGO_VERSION override wins)
try-import %workspace%/.bazelrc.git
# Repository root absolute path to set --execution_log_compact_file # Repository root absolute path to set --execution_log_compact_file
#try-import %workspace%/.bazelrc.exec_log_file #try-import %workspace%/.bazelrc.exec_log_file

View File

@ -0,0 +1,4 @@
# Default Mongo Version if a version is not specified. This should point at the next release version
# that master branch is targeting. The Server Triage and Release (STAR) team will upgrade this
# version on the master branch after every release.
common --define=MONGO_VERSION=9.0.0-alpha0

View File

@ -2,7 +2,6 @@ import hashlib
import os import os
import pathlib import pathlib
import platform import platform
import subprocess
import sys import sys
ARCH_NORMALIZE_MAP = { ARCH_NORMALIZE_MAP = {
@ -23,13 +22,7 @@ def get_mongo_arch(args):
return arch return arch
def get_mongo_version(args):
proc = subprocess.run(["git", "describe", "--abbrev=0"], capture_output=True, text=True)
return proc.stdout.strip()[1:]
def write_wrapper_hook_bazelrc(args): def write_wrapper_hook_bazelrc(args):
mongo_version = get_mongo_version(args)
mongo_arch = get_mongo_arch(args) mongo_arch = get_mongo_arch(args)
python = sys.executable python = sys.executable
@ -50,7 +43,6 @@ def write_wrapper_hook_bazelrc(args):
bazelrc_contents = f""" bazelrc_contents = f"""
common --define=MONGO_ARCH={mongo_arch} common --define=MONGO_ARCH={mongo_arch}
common --define=MONGO_VERSION={mongo_version}
build --workspace_status_command="{python} {workspace_status}" build --workspace_status_command="{python} {workspace_status}"
""" """

View File

@ -4,7 +4,7 @@ import glob
import http import http
import os import os
import shutil import shutil
from subprocess import DEVNULL, STDOUT, CalledProcessError, call, check_output from subprocess import DEVNULL, STDOUT, call, check_output
import requests import requests
import structlog import structlog
@ -35,18 +35,31 @@ MASTER_RELEASES_REMOTE_FILE = (
LOGGER = structlog.getLogger(__name__) LOGGER = structlog.getLogger(__name__)
BAZELRC_DEFAULT_MONGO_VERSION = ".bazelrc.target_mongo_version"
def generate_mongo_version_file(): def generate_mongo_version_file():
"""Generate the mongo version data file. Should only be called in the root of the mongo directory.""" """Generate the mongo version data file. Should only be called in the root of the mongo directory."""
# Read the MONGO_VERSION from .bazelrc.target_mongo_version
# The file contains a line like: common --define=MONGO_VERSION=8.2.2
try: try:
res = check_output("git describe", shell=True, text=True) with open(BAZELRC_DEFAULT_MONGO_VERSION, "r") as f:
except CalledProcessError as exp: for line in f:
raise ChildProcessError("Failed to run git describe to get the latest tag") from exp if "MONGO_VERSION=" in line:
# Extract the version after "MONGO_VERSION="
version = line.split("MONGO_VERSION=")[1].strip()
break
else:
raise ValueError(f"MONGO_VERSION not found in {BAZELRC_DEFAULT_MONGO_VERSION}")
except FileNotFoundError as exp:
raise FileNotFoundError(
f"Failed to read version from {BAZELRC_DEFAULT_MONGO_VERSION}"
) from exp
# Write the current MONGO_VERSION to a data file. # Write the current MONGO_VERSION to a data file.
with open(_config.MONGO_VERSION_FILE, "w") as mongo_version_fh: with open(_config.MONGO_VERSION_FILE, "w", encoding="utf-8") as mongo_version_fh:
# E.g. res = 'r5.1.0-alpha-597-g8c345c6693\n' # E.g. version = '8.2.2'
res = res[1:] # Remove the leading "r" character. mongo_version_fh.write("mongo_version: " + version + "\n")
mongo_version_fh.write("mongo_version: " + res)
@retry(tries=5, delay=3) @retry(tries=5, delay=3)

View File

@ -53,19 +53,6 @@ def get_git_version():
return open(git_ver, "r").read().strip() return open(git_ver, "r").read().strip()
def get_git_describe():
"""Return 'git describe --abbrev=7'."""
with open(os.devnull, "r+") as devnull:
proc = subprocess.Popen(
"git describe --abbrev=7",
stdout=subprocess.PIPE,
stderr=devnull,
stdin=devnull,
shell=True,
)
return proc.communicate()[0].strip().decode("utf-8")
def execsys(args): def execsys(args):
"""Execute a subprocess of 'args'.""" """Execute a subprocess of 'args'."""
if isinstance(args, str): if isinstance(args, str):

View File

@ -40,8 +40,8 @@ For some of the versions we are using such generic names as `latest`, `last-lts`
- `last-continuous` - the latest Rapid release version. In Evergreen, the version that was - `last-continuous` - the latest Rapid release version. In Evergreen, the version that was
downloaded from the Rapid release branch project. It resolves to the entry in downloaded from the Rapid release branch project. It resolves to the entry in
`featureCompatibilityVersions` of [releases.yml](../../src/mongo/util/version/releases.yml) that `featureCompatibilityVersions` of [releases.yml](../../src/mongo/util/version/releases.yml) that
looks older than the output of `git describe`. Will not be tested against if it is listed in looks older than the version specified in `.bazelrc.target_mongo_version`. Will not be tested
`eolVersions` as being end of life. against if it is listed in `eolVersions` as being end of life.
Note: The latest release.yml file from master is always used, even fetched remotely when on another Note: The latest release.yml file from master is always used, even fetched remotely when on another
branch. branch.

View File

@ -126,7 +126,9 @@ bazel_evergreen_shutils::extract_config_flags() {
# Adds --config=public-release-rbe or --config=public-release-local if this is a release-ish build. # Adds --config=public-release-rbe or --config=public-release-local if this is a release-ish build.
bazel_evergreen_shutils::maybe_release_flag() { bazel_evergreen_shutils::maybe_release_flag() {
local local_arg="$1" local local_arg="$1"
if [[ "${release_rbe:-}" == "true" ]]; then if [[ -n "${MONGO_VERSION_OVERRIDE:-}" ]]; then
echo "$local_arg --config=public-release"
elif [[ "${release_rbe:-}" == "true" ]]; then
echo "$local_arg --config=public-release-rbe" # release with RBE (Remote Build Execution) echo "$local_arg --config=public-release-rbe" # release with RBE (Remote Build Execution)
elif [[ "${is_patch:-}" == "true" || -z "${push_bucket:-}" || "${compiling_for_test:-}" == "true" ]]; then elif [[ "${is_patch:-}" == "true" || -z "${push_bucket:-}" || "${compiling_for_test:-}" == "true" ]]; then
echo "$local_arg" # non-release echo "$local_arg" # non-release

View File

@ -1,13 +1,11 @@
#!/bin/bash #!/bin/bash
# For FCV testing only. # For FCV testing only.
# Tag the local branch with the new tag before running tests. # Output the version from .bazelrc.target_mongo_version before running tests.
set -o errexit set -o errexit
set -o verbose set -o verbose
cd src cd src
git config user.name "Evergreen patch build" echo "common --define=MONGO_VERSION=5.1.0-alpha" >.bazelrc.target_mongo_version
git config user.email "evergreen@mongodb.com" echo "r$(grep -oP '(?<=MONGO_VERSION=)[^\s]+' .bazelrc.target_mongo_version)"
git tag -a r5.1.0-alpha -m 5.1.0-alpha
git describe

View File

@ -5,8 +5,9 @@ cd src
set -o errexit set -o errexit
set -o verbose set -o verbose
# We get the raw version string (r1.2.3-45-gabcdef) from git
MONGO_VERSION=$(git describe --abbrev=7) # Extract version from .bazelrc.target_mongo_version (e.g., "common --define=MONGO_VERSION=8.3.0-rc1003")
MONGO_VERSION="r$(grep -oP '(?<=MONGO_VERSION=)[^\s]+' .bazelrc.target_mongo_version)"
# If the project is sys-perf (or related), add the string -sys-perf to the version # If the project is sys-perf (or related), add the string -sys-perf to the version
if [[ "${project}" == sys-perf* ]]; then if [[ "${project}" == sys-perf* ]]; then
@ -18,6 +19,25 @@ fi
if [ "${is_patch}" = "true" ]; then if [ "${is_patch}" = "true" ]; then
MONGO_VERSION="$MONGO_VERSION-patch-${version_id}" MONGO_VERSION="$MONGO_VERSION-patch-${version_id}"
fi fi
# Forcefully override the version for purposes of testing against a different version than the
# branch is targeting.
#
# This disables all remote caching, since we're bypassing the check above that would mark the
# build as a development build.
#
# Artifacts from runs with this enabled still should not be used for a final (non-rc) public release
# unless the associated `test_packages` task has completed successfully.
if [[ -n "${MONGO_VERSION_OVERRIDE}" ]]; then
MONGO_VERSION="${MONGO_VERSION_OVERRIDE}"
fi
# For commit builds, append the last 8 characters of the git revision to the version string.
if [[ "${requester}" == "commit" ]]; then
GIT_REV=$(git rev-parse HEAD)
MONGO_VERSION="${MONGO_VERSION}-${GIT_REV: -8}"
fi
echo "MONGO_VERSION = ${MONGO_VERSION}" echo "MONGO_VERSION = ${MONGO_VERSION}"
activate_venv activate_venv

View File

@ -26,11 +26,17 @@ if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "win32" ]]; then
echo "common --action_env=TMP=Z:/b" >>.bazelrc.evergreen echo "common --action_env=TMP=Z:/b" >>.bazelrc.evergreen
echo "common --action_env=TEMP=Z:/b" >>.bazelrc.evergreen echo "common --action_env=TEMP=Z:/b" >>.bazelrc.evergreen
echo "BAZELISK_HOME=${abs_path}/bazelisk_home" >>.bazeliskrc echo "BAZELISK_HOME=${abs_path}/bazelisk_home" >>.bazeliskrc
echo "common --define GIT_COMMIT_HASH=$(git rev-parse HEAD)" >>.bazelrc.git GIT_REV=$(git rev-parse HEAD)
echo "common --define GIT_COMMIT_HASH=${GIT_REV}" >>.bazelrc.git
else else
echo "startup --output_user_root=${TMPDIR}/bazel-output-root" >.bazelrc.evergreen echo "startup --output_user_root=${TMPDIR}/bazel-output-root" >.bazelrc.evergreen
echo "BAZELISK_HOME=${TMPDIR}/bazelisk_home" >>.bazeliskrc echo "BAZELISK_HOME=${TMPDIR}/bazelisk_home" >>.bazeliskrc
echo "common --define GIT_COMMIT_HASH=$(git rev-parse HEAD)" >>.bazelrc.git GIT_REV=$(git rev-parse HEAD)
echo "common --define GIT_COMMIT_HASH=${GIT_REV}" >>.bazelrc.git
fi
if [[ "${requester}" == "commit" ]]; then
echo "common --define MONGO_VERSION=$(grep -oP 'MONGO_VERSION=\K.*' .bazelrc.target_mongo_version)-${GIT_REV: -8}" >>.bazelrc.git
fi fi
if [[ "${evergreen_remote_exec}" != "on" ]]; then if [[ "${evergreen_remote_exec}" != "on" ]]; then

View File

@ -3,7 +3,14 @@ cd src
set -o errexit set -o errexit
set -o verbose set -o verbose
version=$(git describe --tags --always --dirty) # Extract version from .bazelrc.target_mongo_version (e.g., "common --define=MONGO_VERSION=8.2.2")
version="r$(grep -oP '(?<=MONGO_VERSION=)[^\s]+' .bazelrc.target_mongo_version)"
# For commit builds, append the last 8 characters of the git revision to the version string.
if [[ "${requester:-}" == "commit" ]]; then
GIT_REV=$(git rev-parse HEAD)
version="${version}-${GIT_REV: -8}"
fi
if [ ${IS_RELEASE} = 'true' ]; then if [ ${IS_RELEASE} = 'true' ]; then
version="${version#r}" version="${version#r}"

View File

@ -642,14 +642,14 @@ The logic for determining our generic FCVs is:
## Branch Cut and Upgrading FCVs ## Branch Cut and Upgrading FCVs
Since the FCV generation logic is entirely dependent on the git tag, the Server Triage and Release Since the FCV generation logic is entirely dependent on the version specified in
(STAR) team will upgrade the git tag on the master branch after every release. When this happens, to `.bazelrc.target_mongo_version`, the Server Triage and Release (STAR) team will upgrade this version
correctly build mongo after every release, developers will need to pull the new git tag. on the master branch after every release. When this happens, to correctly build mongo after every
release, developers will need to pull the new git tag.
This can be done by using the `--tags` option (i.e., running `git fetch --tags`) after the STAR team Developers may see what the current version is by checking `.bazelrc.target_mongo_version`. After
has introduced the new git tag. Developers may also see what their latest git tag is by running pulling the latest version changes, it will be necessary to recompile so that the new `releases.h`
`git describe`. After fetching the latest git tag, it will be necessary to recompile so that the new file can be generated.
`releases.h` file can be generated.
# Feature Flags # Feature Flags