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 8, 2025
1 parent 7508f92 commit da131b1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
31 changes: 21 additions & 10 deletions buildbot.tac
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
# -*- 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 = "."
# 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"
configfile = os.path.join(buildbot_tac_dir, 'master.cfg')

# 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

logfile = LogFile.fromFullPath(
os.path.join(log_basedir, "%s"),
Expand Down
14 changes: 10 additions & 4 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 All @@ -69,7 +73,9 @@ gs = reporters.GitHubStatusPush(
)
c["services"].append(gs)
c["secretsProviders"] = [
secrets.SecretInAFile(dirname="/srv/buildbot/master/master-credential-provider")
# SecretsInAFile requires absolute path.
secrets.SecretInAFile(dirname=os.path.join(base_dir,
'master-credential-provider'))
]

####### PROJECT IDENTITY
Expand Down

0 comments on commit da131b1

Please sign in to comment.