Skip to content

Commit

Permalink
buildbot: split targets builds into two phases, saves diskspace
Browse files Browse the repository at this point in the history
  • Loading branch information
pktpls committed Nov 7, 2024
1 parent 600b9b2 commit cf02bf1
Showing 1 changed file with 88 additions and 9 deletions.
97 changes: 88 additions & 9 deletions roles/buildbot/files/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,17 @@ def targetsTarFile(props):


def targetsTargetFactory(f, wwwPrefix, wwwURL, alpineVersion):

tarfile = targetsTarFile
wwwpath = util.Interpolate("builds/targets/%(prop:origbuildnumber)s/")
wwwdir = util.Interpolate(
"%(kw:prefix)s/%(kw:wwwpath)s", prefix=wwwPrefix, wwwpath=wwwpath
)
wwwurl = util.Interpolate("%(kw:url)s/%(kw:wwwpath)s", url=wwwURL, wwwpath=wwwpath)

f.addStep(
steps.ShellCommand(
name="build",
name="build tunneldigger",
haltOnFailure=True,
interruptSignal="TERM", # podman can't proxy the default KILL signal
command=[
Expand Down Expand Up @@ -350,7 +358,6 @@ def targetsTargetFactory(f, wwwPrefix, wwwURL, alpineVersion):
&& git submodule init \
&& git submodule update \
&& env FALTER_VARIANT=tunneldigger build/build.sh %(prop:falterVersion)s %(prop:target)s all \
&& env FALTER_VARIANT=notunnel build/build.sh %(prop:falterVersion)s %(prop:target)s all \
) >&2 \
&& cd /root/falter-builter/out/%(prop:falterVersion)s \
&& tar -c *' > out.tar \
Expand All @@ -361,25 +368,87 @@ def targetsTargetFactory(f, wwwPrefix, wwwURL, alpineVersion):
)
)

tarfile = targetsTarFile
wwwpath = util.Interpolate("builds/targets/%(prop:origbuildnumber)s/")
wwwdir = util.Interpolate(
"%(kw:prefix)s/%(kw:wwwpath)s", prefix=wwwPrefix, wwwpath=wwwpath
f.addStep(
steps.FileUpload(
name="upload tunneldigger",
haltOnFailure=True,
workersrc="out.tar",
masterdest=tarfile,
url=wwwurl,
urlText=wwwurl,
)
)
wwwurl = util.Interpolate("%(kw:url)s/%(kw:wwwpath)s", url=wwwURL, wwwpath=wwwpath)

f.addStep(
steps.MasterShellCommand(
name="extract tunneldigger",
haltOnFailure=True,
command=[
"sh",
"-c",
util.Interpolate(
"mkdir -vp %(kw:wwwdir)s && tar -v -C %(kw:wwwdir)s -xf %(kw:tarfile)s",
tarfile=tarfile,
wwwdir=wwwdir,
),
],
)
)

f.addStep(
steps.ShellCommand(
name="cleanup tunneldigger",
alwaysRun=True,
warnOnFailure=False,
command=["sh", "-c", "rm -vf out.tar"],
)
)

# same thing again, but for the "notunnel" falter image variant.
# we do both variants in separate steps to save ramdisk space (= RAM).
f.addStep(
steps.ShellCommand(
name="build notunnel",
haltOnFailure=True,
interruptSignal="TERM", # podman can't proxy the default KILL signal
command=[
"sh",
"-c",
util.Interpolate(
"""\
podman run -i --rm --log-driver=none docker.io/library/alpine:%(kw:alpineVersion)s sh -c '\
( \
apk add git bash wget zstd xz gzip unzip grep diffutils findutils coreutils build-base gcc abuild binutils ncurses-dev gawk bzip2 gettext perl python3 rsync sqlite flex libxslt \
&& git clone %(prop:repository)s /root/falter-builter \
&& cd /root/falter-builter/ \
&& git checkout %(prop:got_revision)s \
&& git submodule init \
&& git submodule update \
&& env FALTER_VARIANT=notunnel build/build.sh %(prop:falterVersion)s %(prop:target)s all \
) >&2 \
&& cd /root/falter-builter/out/%(prop:falterVersion)s \
&& tar -c *' > out.tar \
""",
alpineVersion=alpineVersion,
),
],
)
)

f.addStep(
steps.FileUpload(
name="upload",
name="upload notunnel",
haltOnFailure=True,
workersrc="out.tar",
masterdest=tarfile,
url=wwwurl,
urlText=wwwurl,
)
)

f.addStep(
steps.MasterShellCommand(
name="extract",
name="extract notunnel",
haltOnFailure=True,
command=[
"sh",
Expand All @@ -392,6 +461,16 @@ def targetsTargetFactory(f, wwwPrefix, wwwURL, alpineVersion):
],
)
)

f.addStep(
steps.ShellCommand(
name="cleanup notunnel",
alwaysRun=True,
warnOnFailure=False,
command=["sh", "-c", "rm -vf out.tar"],
)
)

f.addStep(
steps.MasterShellCommand(
name="cleanup master",
Expand Down

0 comments on commit cf02bf1

Please sign in to comment.