Skip to content

Commit

Permalink
Update buildbot.tac and master.cfg for all autogen masters
Browse files Browse the repository at this point in the history
buildbot.tac as the entrypoint for a buildbot master should use relative
paths based on the deployment directory structure. Furthermore, the
basedir should be set to <srcdir> so that all imports will work relative
to <srcdir>, not the location of buildbot.tac or master.cfg.
  • Loading branch information
cvicentiu committed Jan 12, 2025
1 parent 80b0a1d commit 2082c8f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
38 changes: 26 additions & 12 deletions buildbot.tac
Original file line number Diff line number Diff line change
@@ -1,30 +1,44 @@
# -*- python -*-
# ex: set filetype=python:
import os

from twisted.application import service
from twisted.python.log import FileLogObserver, ILogObserver
from twisted.python.logfile import LogFile

from buildbot.master import BuildMaster

basedir = "."
log_basedir = "/var/log/buildbot/"
# This buildbot.tac file is a basis for all "autogen" masters.
# The folder structure for autogen masters is:
#
# autogen
# └── aarch64-master-0
#    ├── buildbot.tac
#     ├── master.cfg
#     ├── master-config.yaml
#     └── master-private.cfg
#
# Thus basedir is two levels below this file"s position.
buildbot_tac_dir = os.path.abspath(os.path.dirname(__file__))
basedir = os.path.abspath(f"{buildbot_tac_dir}/../../")

# Hard coded as it runs in containers.
# TODO(cvicentiu) this should come as an environment variable.
log_basedir = "/var/log/buildbot"

rotateLength = 20000000
maxRotatedFiles = 30
configfile = "master.cfg"
# Last two directories. autogen and <master-name>
cfg_from_basedir = os.path.normpath(
buildbot_tac_dir).split(os.sep)[-2:] + ["master.cfg"]

configfile = os.path.join(*cfg_from_basedir)
# Default umask for server
umask = None

# if this is a relocatable tac file, get the directory containing the TAC
if basedir == ".":
import os

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

# note: this line is matched against to check that this is a buildmaster
# directory; do not edit it.
application = service.Application('buildmaster') # fmt: skip
from twisted.python.log import FileLogObserver, ILogObserver
from twisted.python.logfile import LogFile
application = service.Application("buildmaster") # fmt: skip

logfile = LogFile.fromFullPath(
os.path.join(log_basedir, "%s"),
Expand Down
10 changes: 7 additions & 3 deletions master.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ from utils import (
uploadDebArtifacts,
)

with open("master-config.yaml", "r") as f:
master_config = yaml.safe_load(f)
cfg_dir = os.path.abspath(os.path.dirname(__file__))
# Autogen master, see buildbot.tac for why this is the case.
base_dir = os.path.abspath(f'{cfg_dir}/../../')
with open(os.path.join(cfg_dir, "master-config.yaml"), "r") as file:
master_config = yaml.safe_load(file)

# This is the dictionary that the buildmaster pays attention to. We also use
# a shorter alias to save typing.
Expand All @@ -46,7 +49,8 @@ c = BuildmasterConfig = {}
# Load the slave, database passwords and 3rd-party tokens from an external
# private file, so that the rest of the configuration can be public.
config = {"private": {}}
exec(open("master-private.cfg").read(), config, {})
with open(os.path.join(cfg_dir, "master-private.cfg"), "r") as file:
exec(file.read(), config, {})

#######
# BUILDBOT SERVICES
Expand Down
2 changes: 1 addition & 1 deletion validate_master_cfg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,5 @@ for dir in autogen/* \
-w "/srv/buildbot/master/" \
$IMAGE \
bash -c "buildbot checkconfig $dir/master.cfg"
echo -e "done\n"
echo "done"
done

0 comments on commit 2082c8f

Please sign in to comment.