Skip to content

Commit 15c342d

Browse files
Foundry deb/rpm triggers
1 parent 21dcaf8 commit 15c342d

8 files changed

Lines changed: 181 additions & 20 deletions

File tree

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,54 @@
1+
from pathlib import Path
2+
3+
import yaml
4+
15
from configuration.builders.base import GenericBuilder
2-
from configuration.builders.sequences.foundry import dispatcher
6+
from configuration.builders.sequences.foundry import autobake, dispatcher
7+
8+
with open(Path(__file__).parent / "foundry.yaml") as f:
9+
_FOUNDRY_CONFIG = yaml.safe_load(f)
10+
11+
_SEQUENCE_BY_PACKAGE_TYPE = {
12+
"rpm": autobake.rpm,
13+
"deb": autobake.deb,
14+
}
15+
16+
17+
def foundry_scheduler_name(mariadb_version):
18+
return f"foundry_{mariadb_version.replace('.', '_')}_scheduler"
19+
20+
21+
FOUNDRY_BUILDERS_BY_ARCH = {}
22+
# Builders grouped by (ops, os version), regardless of arch.
23+
FOUNDRY_BUILDERS_BY_PACKAGE = {}
24+
for package_config in _FOUNDRY_CONFIG["packages"]:
25+
ops = package_config["ops"]
26+
version = package_config["version"]
27+
package = f"{ops}-{version}"
28+
sequence_fn = _SEQUENCE_BY_PACKAGE_TYPE[package_config["type"]]
29+
for arch in package_config["arch"]:
30+
builder = GenericBuilder(
31+
name=f"foundry-{arch}-{ops}-{version}",
32+
sequences=[sequence_fn()],
33+
)
34+
FOUNDRY_BUILDERS_BY_ARCH.setdefault(arch, []).append(builder)
35+
FOUNDRY_BUILDERS_BY_PACKAGE.setdefault(package, []).append(builder)
36+
37+
# Supported MariaDB versions, and which packages get built for each one.
38+
# Configured in configuration/builders/definitions/foundry/foundry.yaml.
39+
FOUNDRY_MARIADB_VERSIONS = _FOUNDRY_CONFIG["mariadb_versions"]
40+
for packages in FOUNDRY_MARIADB_VERSIONS.values():
41+
for package in packages:
42+
assert package in FOUNDRY_BUILDERS_BY_PACKAGE, f"Unknown foundry package: {package}"
343

444
DISPATCHER_BUILDER = GenericBuilder(
545
name="foundry-trigger-builders",
6-
sequences=[dispatcher.trigger_foundry()],
7-
)
46+
sequences=[
47+
dispatcher.trigger_foundry(
48+
[
49+
(foundry_scheduler_name(version), {"mariadb_version": version})
50+
for version in FOUNDRY_MARIADB_VERSIONS
51+
]
52+
)
53+
],
54+
)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
# Foundry package builders: one builder per (package, arch) combination.
3+
packages:
4+
- ops: centosstream
5+
version: "9"
6+
type: rpm
7+
arch:
8+
- amd64
9+
- aarch64
10+
11+
- ops: debian
12+
version: "12"
13+
type: deb
14+
arch:
15+
- amd64
16+
- aarch64
17+
18+
# Supported MariaDB versions, and which packages (by "{ops}-{version}") get
19+
# built for each one. Add or remove a version here to change what
20+
# "foundry-trigger-builders" dispatches.
21+
mariadb_versions:
22+
"11.4":
23+
- centosstream-9
24+
- debian-12
25+
"11.8":
26+
- debian-12
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from configuration.builders.infra.runtime import (
2+
BuildSequence,
3+
DockerConfig,
4+
InContainer,
5+
)
6+
from configuration.steps.remote import PropFromShellStep, ShellStep
7+
from configuration.steps.commands.util import PrintEnvironmentDetails
8+
9+
_MARIADB_VERSION_ENV = [("MARIADB_VERSION", "%(prop:mariadb_version)s")]
10+
11+
12+
def deb():
13+
sequence = BuildSequence()
14+
sequence.add_step(
15+
ShellStep(command=PrintEnvironmentDetails(), env_vars=_MARIADB_VERSION_ENV)
16+
)
17+
return sequence
18+
19+
20+
def rpm():
21+
sequence = BuildSequence()
22+
sequence.add_step(
23+
ShellStep(command=PrintEnvironmentDetails(), env_vars=_MARIADB_VERSION_ENV)
24+
)
25+
return sequence
Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
from configuration.builders.infra.runtime import (
2-
BuildSequence,
3-
DockerConfig,
4-
InContainer,
5-
)
6-
from configuration.steps.remote import PropFromShellStep, ShellStep
7-
from configuration.steps.commands.util import PrintEnvironmentDetails
1+
from configuration.builders.infra.runtime import BuildSequence
2+
from configuration.steps.commands import trigger
83

94

10-
11-
def trigger_foundry():
5+
def trigger_foundry(trigger_specs):
6+
# trigger_specs: list of (schedulername, properties) pairs -- see
7+
# configuration/builders/definitions/foundry/builders.py for how the
8+
# MariaDB-version/package matrix is turned into this list.
129
sequence = BuildSequence()
13-
sequence.add_step(ShellStep(command=PrintEnvironmentDetails()))
10+
sequence.add_step(trigger.FoundryDispatch(trigger_specs))
1411
return sequence

configuration/schedulers/foundry.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import configuration.builders.definitions.foundry.builders as foundry_builders
22
from buildbot.plugins import schedulers, util
33

4-
5-
FOUNDRY_SCHEDULERS = []
6-
FOUNDRY_SCHEDULERS.append(
4+
# Force build entry point for the dispatcher. Must be loaded on whichever
5+
# master serves the www UI, since ForceScheduler availability is resolved
6+
# per-process (master.allSchedulers()), not shared via the DB.
7+
FOUNDRY_FORCE_SCHEDULERS = []
8+
FOUNDRY_FORCE_SCHEDULERS.append(
79
schedulers.ForceScheduler(
810
name="foundry_force_scheduler",
911
builderNames=[foundry_builders.DISPATCHER_BUILDER.name],
@@ -17,4 +19,25 @@
1719
)
1820
]
1921
)
20-
)
22+
)
23+
24+
# One Triggerable per supported MariaDB version, holding whichever packages
25+
# that version builds -- see FOUNDRY_MARIADB_VERSIONS in
26+
# configuration/builders/definitions/foundry/foundry.yaml. The dispatcher
27+
# builder (foundry-trigger-builders) fires each of these once, setting
28+
# mariadb_version, via getSchedulersAndProperties in
29+
# configuration/steps/commands/trigger.py.
30+
# Must be loaded on whichever master executes the dispatcher build (i.e. the
31+
# master owning its workers), since Trigger steps look schedulers up on
32+
# their own process (master.scheduler_manager.namedServices).
33+
FOUNDRY_TRIGGERABLE_SCHEDULERS = [
34+
schedulers.Triggerable(
35+
name=foundry_builders.foundry_scheduler_name(version),
36+
builderNames=[
37+
builder.name
38+
for package in packages
39+
for builder in foundry_builders.FOUNDRY_BUILDERS_BY_PACKAGE[package]
40+
],
41+
)
42+
for version, packages in foundry_builders.FOUNDRY_MARIADB_VERSIONS.items()
43+
]

configuration/steps/commands/trigger.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from buildbot.plugins import steps
22
from buildbot.process.properties import Property
3+
from buildbot.steps.trigger import Trigger as BuildbotTrigger
34
from constants import SAVED_PACKAGE_BRANCHES
45
from utils import (
56
hasDockerLibrary,
@@ -90,6 +91,34 @@ def __init__(self):
9091
super().__init__(self.name, self.schedulername, self.doStepIf, properties)
9192

9293

94+
class _FoundryDispatchStep(BuildbotTrigger):
95+
def __init__(self, trigger_specs, **kwargs):
96+
self.trigger_specs = trigger_specs
97+
super().__init__(**kwargs)
98+
99+
# Buildbot's dynamic-trigger extension point: lets one step fan out to a
100+
# different set of schedulers/properties per (mariadb_version, package)
101+
# pair, instead of needing one static Trigger step per version.
102+
def getSchedulersAndProperties(self):
103+
return self.trigger_specs
104+
105+
106+
class FoundryDispatch:
107+
def __init__(self, trigger_specs):
108+
# trigger_specs: list of (schedulername, properties) pairs, one per
109+
# (mariadb_version, package) combination to fan out to.
110+
self.trigger_specs = trigger_specs
111+
112+
def generate(self):
113+
return _FoundryDispatchStep(
114+
trigger_specs=self.trigger_specs,
115+
name="Trigger Foundry Builders",
116+
schedulerNames=sorted({name for name, _ in self.trigger_specs}),
117+
waitForFinish=False,
118+
updateSourceStamp=False,
119+
)
120+
121+
93122
class Install(Server):
94123
def __init__(self):
95124
self.name = "Trigger Install Builders"

master-migration/master.cfg

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ from configuration.schedulers.connectors import (
3030
CONCPP_SCHEDULERS,
3131
CONODBC_SCHEDULERS,
3232
)
33+
from configuration.schedulers.foundry import FOUNDRY_TRIGGERABLE_SCHEDULERS
3334
from configuration.workers import worker
3435
from master_common import IS_CHECKCONFIG, base_master_config
3536

@@ -48,7 +49,9 @@ c = BuildmasterConfig = base_master_config(config)
4849
# Do not import the schedulers from master_common since this master does not use any
4950
# TODO (Razvan): Schedulers/Services do not need to be defined for every master, this can be the job of a control-plane master
5051
c["schedulers"] = []
51-
c["schedulers"].extend(CONODBC_SCHEDULERS + CONCPP_SCHEDULERS + CONC_SCHEDULERS)
52+
c["schedulers"].extend(
53+
CONODBC_SCHEDULERS + CONCPP_SCHEDULERS + CONC_SCHEDULERS + FOUNDRY_TRIGGERABLE_SCHEDULERS
54+
)
5255

5356
## ------------------------------------------------------------------- ##
5457
## WORKER POOL ##
@@ -487,6 +490,17 @@ c["builders"].append(
487490
)
488491
)
489492

493+
# Foundry package builders, triggered per MariaDB version by the dispatcher
494+
for arch, builders in foundry_builders.FOUNDRY_BUILDERS_BY_ARCH.items():
495+
for builder in builders:
496+
c["builders"].append(
497+
builder.get_config(
498+
workers=FOUNDRY_WORKERS_BY_ARCH.get(arch, []),
499+
tags=["foundry"],
500+
jobs=1,
501+
)
502+
)
503+
490504

491505
## ------------------------------------------------------------------- ##
492506
## REPORTERS ##

master-web/master.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import os
66

77
from buildbot.plugins import schedulers, util
88
from flask import Flask, render_template
9-
from configuration.schedulers.foundry import FOUNDRY_SCHEDULERS
9+
from configuration.schedulers.foundry import FOUNDRY_FORCE_SCHEDULERS
1010
from master_common import base_master_config
1111
from pathlib import Path
1212
from utils import upstream_branch_fn
@@ -117,7 +117,7 @@ c["schedulers"] = []
117117
# looks at master.allSchedulers() in-memory, it is not DB-backed), so they
118118
# must be loaded on whichever master serves the www UI for the "Force" button
119119
# to show up, regardless of which master owns the builder's workers.
120-
c["schedulers"].extend(FOUNDRY_SCHEDULERS)
120+
c["schedulers"].extend(FOUNDRY_FORCE_SCHEDULERS)
121121

122122
# upstream scheduling
123123
schedulerTarball = schedulers.AnyBranchScheduler(

0 commit comments

Comments
 (0)