Skip to content

Commit

Permalink
All buildbot.tac files refactor - use Path
Browse files Browse the repository at this point in the history
Autogen buildbot.tac sets the basedir as two folders up, while other
buildbot.tac files set basedir as one folder up.

All the files are the same otherwise.
  • Loading branch information
cvicentiu committed Feb 5, 2025
1 parent 18c63a8 commit 7a9cf67
Show file tree
Hide file tree
Showing 8 changed files with 248 additions and 121 deletions.
27 changes: 14 additions & 13 deletions buildbot.tac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- python -*-
# ex: set filetype=python:
import os
from pathlib import Path

from twisted.application import service
from twisted.python.log import FileLogObserver, ILogObserver
Expand All @@ -18,39 +18,40 @@ from buildbot.master import BuildMaster
#     ├── 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}/../../")
# Thus basedir is two levels below this file's position.
buildbot_tac_dir = Path(__file__).resolve().parent
basedir = buildbot_tac_dir.parent.parent

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

rotateLength = 20000000
rotateLength = 10000000
maxRotatedFiles = 30

last_two_dirs = os.path.normpath(buildbot_tac_dir).split(os.sep)[-2:]
master_name = last_two_dirs[-1]
master_name = buildbot_tac_dir.name
# Last two directories. autogen and <master-name>
cfg_from_basedir = last_two_dirs + ["master.cfg"]
cfg_from_basedir = (buildbot_tac_dir / "master.cfg").relative_to(basedir)

configfile = cfg_from_basedir.as_posix()

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

# note: this line is matched against to check that this is a buildmaster
# directory; do not edit it.
application = service.Application("buildmaster") # fmt: skip
application = service.Application('buildmaster') # fmt: skip

# This logfile is monitored. It must end in .log.
logfile = LogFile.fromFullPath(
os.path.join(log_basedir, f"{master_name}.log"),
str(log_basedir_path / f"{master_name}.log"),
rotateLength=rotateLength,
maxRotatedFiles=maxRotatedFiles,
)
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)

m = BuildMaster(basedir, configfile, umask)
m = BuildMaster(str(basedir), configfile, umask)
m.setServiceParent(application)
m.log_rotation.rotateLength = rotateLength
m.log_rotation.maxRotatedFiles = maxRotatedFiles
50 changes: 34 additions & 16 deletions master-docker-nonstandard-2/buildbot.tac
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
import os
# -*- python -*-
# ex: set filetype=python:
from pathlib import Path

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/"

rotateLength = 20000000
# This buildbot.tac file is a basis for non-autogen masters.
# The folder structure for autogen masters is:
#
# <srcdir>
# └── master-xxxxxx
#    ├── buildbot.tac
#     ├── master.cfg
#     ├── master-config.yaml
#     └── master-private.cfg
#
# Thus basedir is one levels below this file's position.
buildbot_tac_dir = Path(__file__).resolve().parent
basedir = buildbot_tac_dir.parent

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

rotateLength = 10000000
maxRotatedFiles = 30
configfile = "master.cfg"

# Default umask for server
umask = None
master_name = buildbot_tac_dir.name
# Last two directories. autogen and <master-name>
cfg_from_basedir = (buildbot_tac_dir / "master.cfg").relative_to(basedir)

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

basedir = os.path.abspath(os.path.dirname(__file__))
# Default umask for server
umask = None

# 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

# This logfile is monitored. It must end in .log.
logfile = LogFile.fromFullPath(
os.path.join(log_basedir, "master-docker-non-standard-2.log"),
str(log_basedir_path / f"{master_name}.log"),
rotateLength=rotateLength,
maxRotatedFiles=maxRotatedFiles,
)
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)

m = BuildMaster(basedir, configfile, umask)
m = BuildMaster(str(basedir), configfile, umask)
m.setServiceParent(application)
m.log_rotation.rotateLength = rotateLength
m.log_rotation.maxRotatedFiles = maxRotatedFiles
50 changes: 34 additions & 16 deletions master-docker-nonstandard/buildbot.tac
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
import os
# -*- python -*-
# ex: set filetype=python:
from pathlib import Path

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/"

rotateLength = 20000000
# This buildbot.tac file is a basis for non-autogen masters.
# The folder structure for autogen masters is:
#
# <srcdir>
# └── master-xxxxxx
#    ├── buildbot.tac
#     ├── master.cfg
#     ├── master-config.yaml
#     └── master-private.cfg
#
# Thus basedir is one levels below this file's position.
buildbot_tac_dir = Path(__file__).resolve().parent
basedir = buildbot_tac_dir.parent

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

rotateLength = 10000000
maxRotatedFiles = 30
configfile = "master.cfg"

# Default umask for server
umask = None
master_name = buildbot_tac_dir.name
# Last two directories. autogen and <master-name>
cfg_from_basedir = (buildbot_tac_dir / "master.cfg").relative_to(basedir)

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

basedir = os.path.abspath(os.path.dirname(__file__))
# Default umask for server
umask = None

# 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

# This logfile is monitored. It must end in .log.
logfile = LogFile.fromFullPath(
os.path.join(log_basedir, "master-docker-non-standard.log"),
str(log_basedir_path / f"{master_name}.log"),
rotateLength=rotateLength,
maxRotatedFiles=maxRotatedFiles,
)
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)

m = BuildMaster(basedir, configfile, umask)
m = BuildMaster(str(basedir), configfile, umask)
m.setServiceParent(application)
m.log_rotation.rotateLength = rotateLength
m.log_rotation.maxRotatedFiles = maxRotatedFiles
48 changes: 33 additions & 15 deletions master-galera/buildbot.tac
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
import os
# -*- python -*-
# ex: set filetype=python:
from pathlib import Path

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 non-autogen masters.
# The folder structure for autogen masters is:
#
# <srcdir>
# └── master-xxxxxx
#    ├── buildbot.tac
#     ├── master.cfg
#     ├── master-config.yaml
#     └── master-private.cfg
#
# Thus basedir is one levels below this file's position.
buildbot_tac_dir = Path(__file__).resolve().parent
basedir = buildbot_tac_dir.parent

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

rotateLength = 10000000
maxRotatedFiles = 10
configfile = "master.cfg"
maxRotatedFiles = 30

# Default umask for server
umask = None
master_name = buildbot_tac_dir.name
# Last two directories. autogen and <master-name>
cfg_from_basedir = (buildbot_tac_dir / "master.cfg").relative_to(basedir)

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

basedir = os.path.abspath(os.path.dirname(__file__))
# Default umask for server
umask = None

# 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

# This logfile is monitored. It must end in .log.
logfile = LogFile.fromFullPath(
os.path.join(log_basedir, "master-galera.log"),
str(log_basedir_path / f"{master_name}.log"),
rotateLength=rotateLength,
maxRotatedFiles=maxRotatedFiles,
)
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)

m = BuildMaster(basedir, configfile, umask)
m = BuildMaster(str(basedir), configfile, umask)
m.setServiceParent(application)
m.log_rotation.rotateLength = rotateLength
m.log_rotation.maxRotatedFiles = maxRotatedFiles
48 changes: 33 additions & 15 deletions master-libvirt/buildbot.tac
Original file line number Diff line number Diff line change
@@ -1,39 +1,57 @@
import os
# -*- python -*-
# ex: set filetype=python:
from pathlib import Path

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 non-autogen masters.
# The folder structure for autogen masters is:
#
# <srcdir>
# └── master-xxxxxx
#    ├── buildbot.tac
#     ├── master.cfg
#     ├── master-config.yaml
#     └── master-private.cfg
#
# Thus basedir is one levels below this file's position.
buildbot_tac_dir = Path(__file__).resolve().parent
basedir = buildbot_tac_dir.parent

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

rotateLength = 10000000
maxRotatedFiles = 10
configfile = "master.cfg"
maxRotatedFiles = 30

# Default umask for server
umask = None
master_name = buildbot_tac_dir.name
# Last two directories. autogen and <master-name>
cfg_from_basedir = (buildbot_tac_dir / "master.cfg").relative_to(basedir)

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

basedir = os.path.abspath(os.path.dirname(__file__))
# Default umask for server
umask = None

# 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

# This logfile is monitored. It must end in .log.
logfile = LogFile.fromFullPath(
os.path.join(log_basedir, "master-libvirt.log"),
str(log_basedir_path / f"{master_name}.log"),
rotateLength=rotateLength,
maxRotatedFiles=maxRotatedFiles,
)
application.setComponent(ILogObserver, FileLogObserver(logfile).emit)

m = BuildMaster(basedir, configfile, umask)
m = BuildMaster(str(basedir), configfile, umask)
m.setServiceParent(application)
m.log_rotation.rotateLength = rotateLength
m.log_rotation.maxRotatedFiles = maxRotatedFiles
Loading

0 comments on commit 7a9cf67

Please sign in to comment.