SERVER-120949: Remove Tag Based FCV Generation (#49061)
GitOrigin-RevId: 71d11d29d6e9077edbedf4a95bc6b1977666d358
This commit is contained in:
parent
8f676e69ab
commit
aef13e0584
9
.bazelrc
9
.bazelrc
@ -660,9 +660,6 @@ try-import %workspace%/.bazelrc.common_bes
|
||||
# Settings unconditionally written by the 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
|
||||
try-import %workspace%/.bazelrc.local
|
||||
|
||||
@ -678,6 +675,12 @@ try-import %workspace%/.bazelrc.engflow_creds
|
||||
# Flags for 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
|
||||
#try-import %workspace%/.bazelrc.exec_log_file
|
||||
|
||||
|
||||
4
.bazelrc.target_mongo_version
Normal file
4
.bazelrc.target_mongo_version
Normal 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
|
||||
@ -2,7 +2,6 @@ import hashlib
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
ARCH_NORMALIZE_MAP = {
|
||||
@ -23,13 +22,7 @@ def get_mongo_arch(args):
|
||||
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):
|
||||
mongo_version = get_mongo_version(args)
|
||||
mongo_arch = get_mongo_arch(args)
|
||||
|
||||
python = sys.executable
|
||||
@ -50,7 +43,6 @@ def write_wrapper_hook_bazelrc(args):
|
||||
|
||||
bazelrc_contents = f"""
|
||||
common --define=MONGO_ARCH={mongo_arch}
|
||||
common --define=MONGO_VERSION={mongo_version}
|
||||
|
||||
build --workspace_status_command="{python} {workspace_status}"
|
||||
"""
|
||||
|
||||
@ -4,7 +4,7 @@ import glob
|
||||
import http
|
||||
import os
|
||||
import shutil
|
||||
from subprocess import DEVNULL, STDOUT, CalledProcessError, call, check_output
|
||||
from subprocess import DEVNULL, STDOUT, call, check_output
|
||||
|
||||
import requests
|
||||
import structlog
|
||||
@ -35,18 +35,31 @@ MASTER_RELEASES_REMOTE_FILE = (
|
||||
LOGGER = structlog.getLogger(__name__)
|
||||
|
||||
|
||||
BAZELRC_DEFAULT_MONGO_VERSION = ".bazelrc.target_mongo_version"
|
||||
|
||||
|
||||
def generate_mongo_version_file():
|
||||
"""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:
|
||||
res = check_output("git describe", shell=True, text=True)
|
||||
except CalledProcessError as exp:
|
||||
raise ChildProcessError("Failed to run git describe to get the latest tag") from exp
|
||||
with open(BAZELRC_DEFAULT_MONGO_VERSION, "r") as f:
|
||||
for line in f:
|
||||
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.
|
||||
with open(_config.MONGO_VERSION_FILE, "w") as mongo_version_fh:
|
||||
# E.g. res = 'r5.1.0-alpha-597-g8c345c6693\n'
|
||||
res = res[1:] # Remove the leading "r" character.
|
||||
mongo_version_fh.write("mongo_version: " + res)
|
||||
with open(_config.MONGO_VERSION_FILE, "w", encoding="utf-8") as mongo_version_fh:
|
||||
# E.g. version = '8.2.2'
|
||||
mongo_version_fh.write("mongo_version: " + version + "\n")
|
||||
|
||||
|
||||
@retry(tries=5, delay=3)
|
||||
|
||||
@ -53,19 +53,6 @@ def get_git_version():
|
||||
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):
|
||||
"""Execute a subprocess of 'args'."""
|
||||
if isinstance(args, str):
|
||||
|
||||
@ -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
|
||||
downloaded from the Rapid release branch project. It resolves to the entry in
|
||||
`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
|
||||
`eolVersions` as being end of life.
|
||||
looks older than the version specified in `.bazelrc.target_mongo_version`. Will not be tested
|
||||
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
|
||||
branch.
|
||||
|
||||
@ -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.
|
||||
bazel_evergreen_shutils::maybe_release_flag() {
|
||||
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)
|
||||
elif [[ "${is_patch:-}" == "true" || -z "${push_bucket:-}" || "${compiling_for_test:-}" == "true" ]]; then
|
||||
echo "$local_arg" # non-release
|
||||
|
||||
@ -1,13 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 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 verbose
|
||||
|
||||
cd src
|
||||
git config user.name "Evergreen patch build"
|
||||
git config user.email "evergreen@mongodb.com"
|
||||
git tag -a r5.1.0-alpha -m 5.1.0-alpha
|
||||
git describe
|
||||
echo "common --define=MONGO_VERSION=5.1.0-alpha" >.bazelrc.target_mongo_version
|
||||
echo "r$(grep -oP '(?<=MONGO_VERSION=)[^\s]+' .bazelrc.target_mongo_version)"
|
||||
|
||||
@ -5,8 +5,9 @@ cd src
|
||||
|
||||
set -o errexit
|
||||
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 [[ "${project}" == sys-perf* ]]; then
|
||||
@ -18,6 +19,25 @@ fi
|
||||
if [ "${is_patch}" = "true" ]; then
|
||||
MONGO_VERSION="$MONGO_VERSION-patch-${version_id}"
|
||||
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}"
|
||||
|
||||
activate_venv
|
||||
|
||||
@ -26,11 +26,17 @@ if [[ "$OSTYPE" == "cygwin" ]] || [[ "$OSTYPE" == "win32" ]]; then
|
||||
echo "common --action_env=TMP=Z:/b" >>.bazelrc.evergreen
|
||||
echo "common --action_env=TEMP=Z:/b" >>.bazelrc.evergreen
|
||||
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
|
||||
echo "startup --output_user_root=${TMPDIR}/bazel-output-root" >.bazelrc.evergreen
|
||||
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
|
||||
|
||||
if [[ "${evergreen_remote_exec}" != "on" ]]; then
|
||||
|
||||
@ -3,7 +3,14 @@ cd src
|
||||
set -o errexit
|
||||
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
|
||||
version="${version#r}"
|
||||
|
||||
@ -642,14 +642,14 @@ The logic for determining our generic FCVs is:
|
||||
|
||||
## Branch Cut and Upgrading FCVs
|
||||
|
||||
Since the FCV generation logic is entirely dependent on the git tag, the Server Triage and Release
|
||||
(STAR) team will upgrade the 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.
|
||||
Since the FCV generation logic is entirely dependent on the version specified in
|
||||
`.bazelrc.target_mongo_version`, the Server Triage and Release (STAR) team will upgrade this version
|
||||
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
|
||||
has introduced the new git tag. Developers may also see what their latest git tag is by running
|
||||
`git describe`. After fetching the latest git tag, it will be necessary to recompile so that the new
|
||||
`releases.h` file can be generated.
|
||||
Developers may see what the current version is by checking `.bazelrc.target_mongo_version`. After
|
||||
pulling the latest version changes, it will be necessary to recompile so that the new `releases.h`
|
||||
file can be generated.
|
||||
|
||||
# Feature Flags
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user