Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 109 additions & 139 deletions master-libvirt/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# ex: set filetype=python:

import os
from dataclasses import dataclass

from buildbot.plugins import steps, util, worker
from buildbot.steps.shell import Test
from constants import BUILDERS_INSTALL, OS_INFO
from master_common import base_master_config
from utils import canStartBuild, envFromProperties, getScript, nextBuild, printEnv


cfg_dir = os.path.abspath(os.path.dirname(__file__))

# Non autogen master. For now the directory structure is:
Expand All @@ -33,118 +35,81 @@ c = BuildmasterConfig = base_master_config(config)
artifactsURL = os.environ["ARTIFACTS_URL"]


####### UTILS
def getRpmUpgradeStep():
INSTALL_UPGRADE_PROPERTIES_LIST = [
# Must be set to True in BB for upgrade scripts to work
"BB_CI",
# TODO(cvicentiu) compared to arm64 instead of aarch64 in scripts/deb-install.sh
# amd64, aarch64, ppc64le, s390x, x86
"arch",
# Where artifacts are downloaded from ci.mariadb.org
"artifactsURL",
# Impacts upgrade and install logic. Same value as the branch in git
# (incl. bb- prefix and other suffixes).
"branch",
# almalinux, centos, debian, fedora, openeuler, rhel, ubuntu, rockylinux
"dist_name",
# compared to "yes" in rpm-upgrade.sh, but never set.
# TODO(cvicentiu) investigate and fix this.
"is_main_tree",
# TODO(cvicentiu) This should be handled within the script, not BB,
# mariadb_version should be enough.
# Extracted from mariadb_version variable as a separate BB step.
"major_version",
# Eg. mariadb-10.11.12, comes from parent (tarball) builder props,
# based on tarball filename.
"mariadb_version",
# Set from parent (tarball) builder. First two numbers from mariadb_version.
"master_branch",
# TODO(cvicentiu) investigate and remove this one.
# Set to "yes" / "no" within this file, but never used anywhere.
"needsGalera",
# Set to the builder that triggered this install/upgrade
# Used during install scripts to create builder URL.
"parentbuildername",
# TODO(cvicentiu) This should be removed from install / upgrade scripts.
# and finally removed from here.
# Always set to "yes" within this file.
"systemdCapability",
# Set by tarball docker.
"tarbuildnum",
# "server", "all", "columnstore", "deps"
# Impacts which tests are run. Set within this file only.
"test_mode",
# "major", "minor"
# Impacts which tests are run. set within this file.
"test_type",
# Loaded from os_info.yaml. Impacts upgrade & install tests.
"version_name",
]


def _get_test_step(name: str, script: str):
return Test(
name="upgrade",
name=name,
haltOnFailure=True,
description=["testing", "upgrade"],
descriptionDone=["test", "upgrade"],
env=envFromProperties(
[
"BB_CI",
"arch",
"artifactsURL",
"branch",
"dist_name",
"is_main_tree",
"major_version",
"mariadb_version",
"master_branch",
"needsGalera",
"parentbuildername",
"systemdCapability",
"test_mode",
"test_type",
"version_name",
]
),
command=["./rpm-upgrade.sh"],
description=["testing", name],
descriptionDone=["test", name],
env=envFromProperties(INSTALL_UPGRADE_PROPERTIES_LIST),
command=[script],

)


####### UTILS
def getRpmUpgradeStep():
return _get_test_step(name="upgrade", script="./rpm-upgrade.sh")


def getRpmInstallStep():
return Test(
name="install",
haltOnFailure=True,
description=["testing", "install"],
descriptionDone=["test", "install"],
env=envFromProperties(
[
"BB_CI",
"arch",
"artifactsURL",
"branch",
"dist_name",
"major_version",
"mariadb_version",
"master_branch",
"needsGalera",
"parentbuildername",
"systemdCapability",
"test_mode",
"test_type",
"version_name",
]
),
command=["./rpm-install.sh"],
)
return _get_test_step(name="install", script="./rpm-install.sh")


def getDebUpgradeStep():
return Test(
name="upgrade",
haltOnFailure=True,
description=["testing", "upgrade"],
descriptionDone=["test", "upgrade"],
env=envFromProperties(
[
"BB_CI",
"arch",
"artifactsURL",
"branch",
"dist_name",
"major_version",
"mariadb_version",
"master_branch",
"needsGalera",
"parentbuildername",
"systemdCapability",
"test_mode",
"test_type",
"version_name",
]
),
command=["./deb-upgrade.sh"],
)
return _get_test_step(name="upgrade", script="./deb-upgrade.sh")


def getDebInstallStep():
return Test(
name="install",
haltOnFailure=True,
description=["testing", "install"],
descriptionDone=["test", "install"],
env=envFromProperties(
[
"BB_CI",
"arch",
"artifactsURL",
"branch",
"dist_name",
"major_version",
"mariadb_version",
"master_branch",
"needsGalera",
"parentbuildername",
"systemdCapability",
"test_mode",
"test_type",
"version_name",
]
),
command=["./deb-install.sh"],
)
return _get_test_step(name="install", script="./deb-install.sh")


def getMajorVersionStep():
Expand Down Expand Up @@ -208,6 +173,33 @@ f_rpm_upgrade.addStep(getRpmUpgradeStep())
c["workers"] = []
c["builders"] = []


@dataclass
class LibVirtWorkerSpecs:
platform: str
os_name: str
os_version: str

def __post_init__(self):
self.host, self.url = config["private"]["libvirt_workers"][platform]

@property
def name(self) -> str:
return f"{self.host}-{self.os_name}-{self.os_version}-{self.platform}"

@property
def connection_url(self) -> str:
return self.url

@property
def image_path(self) -> str:
return f"/var/libvirt/images/{self.name}",

@property
def password(self) -> str:
return config["private"]["worker_pass"]["libvirt"]


# Add the workers and builds based on the configured install builders (see constants.py)
for builder_name in BUILDERS_INSTALL:
# Parse builder name
Expand All @@ -217,50 +209,28 @@ for builder_name in BUILDERS_INSTALL:

os_info_name = os_name + "-" + os_version

libvirt_worker_name = (
config["private"]["libvirt_workers"][platform][0]
+ "-"
+ os_name
+ "-"
+ os_version
+ "-"
+ platform
)
connection_url = config["private"]["libvirt_workers"][platform][1]
image_path = "/var/libvirt/images/" + libvirt_worker_name
worker_specs = LibVirtWorkerSpecs(platform=platform,
os_name=os_name,
os_version=os_version)

c["workers"].append(
worker.LibVirtWorker(
libvirt_worker_name,
config["private"]["worker_pass"]["libvirt"],
util.Connection(connection_url),
image_path,
worker_specs.name,
worker_specs.password,
util.Connection(worker_specs.connection_url),
worker_specs.image_path,
build_wait_timeout=0,
max_builds=1,
)
)

if builder_type == "deb":
factory_install = f_deb_install
factory_upgrade = f_deb_upgrade
build_arch = platform
elif builder_type == "rpm":
factory_install = f_rpm_install
factory_upgrade = f_rpm_upgrade
build_arch = (
os_name + str(OS_INFO[os_info_name]["version_name"]) + "-" + platform
)

# FIXME - all RPM's should follow the same conventions!
if os_name == "centos" and OS_INFO[os_info_name]["version_name"] >= 9:
if platform == "amd64":
platform = "x86_64"
build_arch = f"centos/{OS_INFO[os_info_name]['version_name']}/{platform}"
factory_install = f_deb_install if builder_type == "deb" else f_rpm_install
factory_upgrade = f_deb_upgrade if builder_type == "deb" else f_rpm_upgrade

c["builders"].append(
util.BuilderConfig(
name=builder_name,
workernames=libvirt_worker_name,
workernames=worker_specs.name,
tags=[os_name, builder_type, "install", "kvm"],
collapseRequests=True,
nextBuild=nextBuild,
Expand All @@ -270,7 +240,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "yes",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
"BB_CI": True,
"artifactsURL": artifactsURL,
},
Expand All @@ -284,7 +254,7 @@ for builder_name in BUILDERS_INSTALL:
c["builders"].append(
util.BuilderConfig(
name=major_upgrade_name,
workernames=libvirt_worker_name,
workernames=worker_specs.name,
tags=[os_name, builder_type, "upgrade", "kvm", "major", "server"],
collapseRequests=True,
nextBuild=nextBuild,
Expand All @@ -294,7 +264,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "yes",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
Copy link
Collaborator

@RazvanLiviuVarzaru RazvanLiviuVarzaru Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cvicentiu We need to test on Dev if a re-build is causing a re-calculation of the "arch" property.
My guess is Yes, but if "arch" is not updated on re-build then we end up with an incompatible change with the scripts.
We need to be sure that we can re-build runs at least for a couple of days in the past.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be logical for properties to be recomputed, but yes, I agree, we should check this.

Copy link
Collaborator

@RazvanLiviuVarzaru RazvanLiviuVarzaru Mar 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this now, the properties are re-computed on rebuild but there are 2 conditions for a production release:

https://buildbot.dev.mariadb.org/#/builders/231/builds/41
arch: "almalinux8-aarch64"

re-run: https://buildbot.dev.mariadb.org/#/builders/231/builds/42
arch: "aarch64"
  1. After this patch is merged to Main, we need to immediately deploy the buildbot configuration changes to PROD and restart master-libvirt
  2. No libvirt builders running at the time of the merge to Main

Why?

  • the worker is downloading the script from the main branch
  • bash_lib changes are incompatible with the current buildbot configuration so both pieces (script,bb config) need to be deployed together

"test_mode": "server",
"test_type": "major",
"BB_CI": True,
Expand All @@ -310,7 +280,7 @@ for builder_name in BUILDERS_INSTALL:
c["builders"].append(
util.BuilderConfig(
name=minor_upgrade_name + "-all",
workernames=libvirt_worker_name,
workernames=worker_specs.name,
tags=[os_name, builder_type, "upgrade", "kvm", "minor", "all"],
collapseRequests=True,
nextBuild=nextBuild,
Expand All @@ -320,7 +290,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "yes",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
"test_mode": "all",
"test_type": "minor",
"BB_CI": True,
Expand All @@ -334,7 +304,7 @@ for builder_name in BUILDERS_INSTALL:
c["builders"].append(
util.BuilderConfig(
name=minor_upgrade_name + "-columnstore",
workernames=libvirt_worker_name,
workernames=worker_specs.name,
tags=[os_name, builder_type, "upgrade", "kvm", "minor", "columnstore"],
collapseRequests=True,
nextBuild=nextBuild,
Expand All @@ -344,7 +314,7 @@ for builder_name in BUILDERS_INSTALL:
"needsGalera": "no",
"dist_name": os_name,
"version_name": OS_INFO[os_info_name]["version_name"],
"arch": build_arch,
"arch": platform,
"test_mode": "columnstore",
"test_type": "minor",
"BB_CI": True,
Expand Down
Loading