Skip to content

Commit

Permalink
Refactor schedulers_definition.py
Browse files Browse the repository at this point in the history
No need to reconstruct the same list over and over, just return a static
variable.
  • Loading branch information
cvicentiu committed Jan 7, 2025
1 parent 9aa4446 commit 6221769
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 115 deletions.
4 changes: 2 additions & 2 deletions master-bintars/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sys.setrecursionlimit(10000)
from common_factories import *
from constants import *
from locks import *
from schedulers_definition import *
from schedulers_definition import SCHEDULERS
from utils import *

FQDN = os.getenv("BUILDMASTER_WG_IP", default="100.64.100.1")
Expand Down Expand Up @@ -97,7 +97,7 @@ c["buildbotNetUsageData"] = None
####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.
c["schedulers"] = getSchedulers()
c["schedulers"] = SCHEDULERS

####### WORKERS

Expand Down
4 changes: 2 additions & 2 deletions master-docker-nonstandard-2/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sys.setrecursionlimit(10000)
from common_factories import *
from constants import *
from locks import *
from schedulers_definition import *
from schedulers_definition import SCHEDULERS
from utils import *

FQDN = os.getenv("BUILDMASTER_WG_IP", default="100.64.100.1")
Expand Down Expand Up @@ -95,7 +95,7 @@ c["buildbotNetUsageData"] = None
####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.
c["schedulers"] = getSchedulers()
c["schedulers"] = SCHEDULERS

####### WORKERS

Expand Down
4 changes: 2 additions & 2 deletions master-docker-nonstandard/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sys.setrecursionlimit(10000)
from common_factories import *
from constants import *
from locks import *
from schedulers_definition import *
from schedulers_definition import SCHEDULERS
from utils import *

FQDN = os.getenv("BUILDMASTER_WG_IP", default="100.64.100.1")
Expand Down Expand Up @@ -95,7 +95,7 @@ c["buildbotNetUsageData"] = None
####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.
c["schedulers"] = getSchedulers()
c["schedulers"] = SCHEDULERS

####### WORKERS

Expand Down
4 changes: 2 additions & 2 deletions master-nonlatent/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sys.setrecursionlimit(10000)
sys.path.insert(0, "/srv/buildbot/master")
from common_factories import *
from locks import *
from schedulers_definition import *
from schedulers_definition import SCHEDULERS
from utils import *

####### VARIABLES
Expand Down Expand Up @@ -92,7 +92,7 @@ c["prioritizeBuilders"] = prioritizeBuilders
####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.
c["schedulers"] = getSchedulers()
c["schedulers"] = SCHEDULERS

####### WORKERS

Expand Down
4 changes: 2 additions & 2 deletions master-protected-branches/master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sys.path.insert(0, "/srv/buildbot/master")
from constants import *
from utils import *
from locks import *
from schedulers_definition import *
from schedulers_definition import SCHEDULERS
from common_factories import *

# This is the dictionary that the buildmaster pays attention to. We also use
Expand Down Expand Up @@ -94,7 +94,7 @@ c["buildbotNetUsageData"] = None
####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.
c["schedulers"] = getSchedulers()
c["schedulers"] = SCHEDULERS

####### WORKERS

Expand Down
4 changes: 2 additions & 2 deletions master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ sys.path.insert(0, "/srv/buildbot/master")
from common_factories import *
from constants import *
from locks import *
from schedulers_definition import *
from schedulers_definition import SCHEDULERS
from utils import *

with open("master-config.yaml", "r") as f:
Expand Down Expand Up @@ -97,7 +97,7 @@ c["buildbotNetUsageData"] = None
####### SCHEDULERS

# Configure the Schedulers, which decide how to react to incoming changes.
c["schedulers"] = getSchedulers()
c["schedulers"] = SCHEDULERS

####### WORKERS

Expand Down
159 changes: 56 additions & 103 deletions schedulers_definition.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from buildbot.interfaces import IProperties
from buildbot.plugins import schedulers, util
from constants import (
builders_autobake,
Expand All @@ -12,149 +13,101 @@
)


####### SCHEDULER HELPER FUNCTIONS
############################
# SCHEDULER HELPER FUNCTIONS
############################
@util.renderer
def getBranchBuilderNames(props):
mBranch = props.getProperty("master_branch")

builders = list(
filter(lambda x: x not in github_status_builders, supportedPlatforms[mBranch])
)

return builders
def branchBuilders(props: IProperties) -> list[str]:
master_branch = props.getProperty("master_branch")
builders = supportedPlatforms[master_branch]
return list(filter(lambda x: x not in github_status_builders, builders))


@util.renderer
def getProtectedBuilderNames(props):
mBranch = props.getProperty("master_branch")

builders = list(
filter(lambda x: x in supportedPlatforms[mBranch], github_status_builders)
)

return builders
def protectedBranchBuilders(props: IProperties) -> list[str]:
master_branch = props.getProperty("master_branch")
builders = supportedPlatforms[master_branch]
return list(filter(lambda x: x in builders, github_status_builders))


@util.renderer
def getAutobakeBuilderNames(props):
builderName = props.getProperty("parentbuildername")
def autobakeBuilders(props: IProperties) -> list[str]:
builder_name = props.getProperty("parentbuildername")
for b in builders_autobake:
if builderName in b:
if builder_name in b:
return [b]
return []


@util.renderer
def getBigtestBuilderNames(props):
builderName = str(props.getProperty("parentbuildername"))

def bigtestBuilders(props: IProperties) -> list[str]:
builder_name = props.getProperty("parentbuildername")
for b in builders_big:
if builderName in b:
if builder_name in b:
return [b]
return []


@util.renderer
def getInstallBuilderNames(props):
builderName = str(props.getProperty("parentbuildername"))

def installBuilders(props: IProperties) -> list[str]:
builder_name = props.getProperty("parentbuildername")
for b in builders_install:
if builderName in b:
if builder_name in b:
builders = [b]
if "rhel" in builderName:
if "rhel" in builder_name:
builders.append(b.replace("rhel", "almalinux"))
builders.append(b.replace("rhel", "rockylinux"))
return builders
return []


@util.renderer
def getUpgradeBuilderNames(props):
builderName = str(props.getProperty("parentbuildername"))

builds = []
def upgradeBuilders(props: IProperties) -> list[str]:
builder_name = props.getProperty("parentbuildername")
builders = []
for b in builders_upgrade:
if builderName in b:
if "rhel" in builderName:
builds.append(b.replace("rhel", "almalinux"))
builds.append(b.replace("rhel", "rockylinux"))
builds.append(b)
return builds
if builder_name in b:
if "rhel" in builder_name:
builders.append(b.replace("rhel", "almalinux"))
builders.append(b.replace("rhel", "rockylinux"))
builders.append(b)
return builders


@util.renderer
def getEcoBuilderNames(props):
builderName = str(props.getProperty("parentbuildername"))

builds = []
def ecoBuilders(props: IProperties) -> list[str]:
builder_name = props.getProperty("parentbuildername")
builders = []
for b in builders_eco:
if builderName in b:
builds.append(b)
return builds
if builder_name in b:
builders.append(b)
return builders


@util.renderer
def getDockerLibraryNames(props):
def dockerLibraryBuilders(props: IProperties) -> list[str]:
return builders_dockerlibrary[0]


@util.renderer
def getWordpressNames(props):
def wordpressBuilders(props: IProperties) -> list[str]:
return builders_wordpress[0]


def getSchedulers():
l = []

l.append(
schedulers.Triggerable(
name="s_upstream_all", builderNames=getBranchBuilderNames
)
)

schedulerProtectedBranches = schedulers.Triggerable(
name="s_protected_branches", builderNames=getProtectedBuilderNames
)
l.append(schedulerProtectedBranches)

schedulerPackages = schedulers.Triggerable(
name="s_packages", builderNames=getAutobakeBuilderNames
)
l.append(schedulerPackages)

schedulerBigtests = schedulers.Triggerable(
name="s_bigtest", builderNames=getBigtestBuilderNames
)
l.append(schedulerBigtests)

schedulerInstall = schedulers.Triggerable(
name="s_install", builderNames=getInstallBuilderNames
)
l.append(schedulerInstall)

schedulerUpgrade = schedulers.Triggerable(
name="s_upgrade", builderNames=getUpgradeBuilderNames
)
l.append(schedulerUpgrade)

schedulerEco = schedulers.Triggerable(name="s_eco", builderNames=getEcoBuilderNames)
l.append(schedulerEco)

schedulerDockerlibrary = schedulers.Triggerable(
name="s_dockerlibrary", builderNames=getDockerLibraryNames
)
l.append(schedulerDockerlibrary)

l.append(schedulers.Triggerable(name="s_wordpress", builderNames=getWordpressNames))

l.append(
schedulers.Triggerable(name="s_release_prep", builderNames=["release-prep"])
)

l.append(
schedulers.Triggerable(
name="s_jepsen", builderNames=["amd64-ubuntu-2204-jepsen-mariadb"]
)
)

return l
SCHEDULERS = [
schedulers.Triggerable(name="s_upstream_all", builderNames=branchBuilders),
schedulers.Triggerable(
name="s_protected_branches", builderNames=protectedBranchBuilders
),
schedulers.Triggerable(name="s_packages", builderNames=autobakeBuilders),
schedulers.Triggerable(name="s_bigtest", builderNames=bigtestBuilders),
schedulers.Triggerable(name="s_install", builderNames=installBuilders),
schedulers.Triggerable(name="s_upgrade", builderNames=upgradeBuilders),
schedulers.Triggerable(name="s_eco", builderNames=ecoBuilders),
schedulers.Triggerable(name="s_dockerlibrary", builderNames=dockerLibraryBuilders),
schedulers.Triggerable(name="s_wordpress", builderNames=wordpressBuilders),
schedulers.Triggerable(name="s_release_prep", builderNames=["release-prep"]),
schedulers.Triggerable(
name="s_jepsen", builderNames=["amd64-ubuntu-2204-jepsen-mariadb"]
),
]

0 comments on commit 6221769

Please sign in to comment.