Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add caching of minimized BTFs #25283

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ variables:
S3_CP_OPTIONS: --no-progress --region us-east-1 --sse AES256
S3_CP_CMD: aws s3 cp $S3_CP_OPTIONS
S3_ARTIFACTS_URI: s3://dd-ci-artefacts-build-stable/$CI_PROJECT_NAME/$CI_PIPELINE_ID
S3_PROJECT_ARTIFACTS_URI: s3://dd-ci-artefacts-build-stable/$CI_PROJECT_NAME
S3_PERMANENT_ARTIFACTS_URI: s3://dd-ci-persistent-artefacts-build-stable/$CI_PROJECT_NAME
S3_SBOM_STORAGE_URI: s3://sbom-root-us1-ddbuild-io/$CI_PROJECT_NAME/$CI_PIPELINE_ID
S3_RELEASE_ARTIFACTS_URI: s3://dd-release-artifacts/$CI_PROJECT_NAME/$CI_PIPELINE_ID
Expand Down
1 change: 1 addition & 0 deletions .gitlab/binary_build/system_probe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
expire_in: 2 weeks
paths:
- $CI_PROJECT_DIR/sysprobe-build-outputs.tar.xz
- $CI_PROJECT_DIR/sysprobe-build-outputs.tar.xz.sum

build_system-probe-x64:
stage: binary_build
Expand Down
14 changes: 14 additions & 0 deletions .gitlab/package_deps_build/package_deps_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,26 @@
tags: ["arch:amd64"]
script:
- cd $CI_PROJECT_DIR
- export BTFS_ETAG=$(aws s3api head-object --region us-east-1 --bucket dd-agent-omnibus --key btfs/$BTFHUB_ARCHIVE_BRANCH/btfs-$ARCH.tar --query ETag --output text | tr -d \")
- export OUTPUTS_HASH=$(sha256sum sysprobe-build-outputs.tar.xz.sum | cut -d' ' -f1)
- export MIN_BTFS_FILENAME=minimized-btfs-$BTFS_ETAG-$OUTPUTS_HASH.tar.xz
- |
# if running all builds, or this is a release branch, skip the cache check
if [[ "$RUN_ALL_BUILDS" != "true" && ! $CI_COMMIT_BRANCH =~ /^[0-9]+\.[0-9]+\.x$/ ]]; then
if aws s3api head-object --region us-east-1 --bucket dd-ci-artefacts-build-stable --key $CI_PROJECT_NAME/btfs/$MIN_BTFS_FILENAME; then
$S3_CP_CMD $S3_PROJECT_ARTIFACTS_URI/btfs/$MIN_BTFS_FILENAME $CI_PROJECT_DIR/minimized-btfs.tar.xz
echo "cached minimized BTFs exist"
exit 0
fi
fi
# cache does not exist, download processed BTFs and minimize
- $S3_CP_CMD $S3_DD_AGENT_OMNIBUS_BTFS_URI/$BTFHUB_ARCHIVE_BRANCH/btfs-$ARCH.tar .
- tar -xf btfs-$ARCH.tar
- tar -xf sysprobe-build-outputs.tar.xz
- inv -e system-probe.generate-minimized-btfs --source-dir "$CI_PROJECT_DIR/btfs-$ARCH" --output-dir "$CI_PROJECT_DIR/minimized-btfs" --bpf-programs "$CI_PROJECT_DIR/pkg/ebpf/bytecode/build/co-re"
- cd minimized-btfs
- tar -cJf $CI_PROJECT_DIR/minimized-btfs.tar.xz *
- $S3_CP_CMD $CI_PROJECT_DIR/minimized-btfs.tar.xz $S3_PROJECT_ARTIFACTS_URI/btfs/$MIN_BTFS_FILENAME
variables:
KUBERNETES_MEMORY_REQUEST: "32Gi"
KUBERNETES_MEMORY_LIMIT: "32Gi"
Expand Down
6 changes: 6 additions & 0 deletions tasks/system_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1780,6 +1780,7 @@ def save_build_outputs(ctx, destfile):

absdest = os.path.abspath(destfile)
count = 0
outfiles = []
with tempfile.TemporaryDirectory() as stagedir:
with open("compile_commands.json") as compiledb:
for outputitem in json.load(compiledb):
Expand All @@ -1794,8 +1795,13 @@ def save_build_outputs(ctx, destfile):
outdir = os.path.join(stagedir, filedir)
ctx.run(f"mkdir -p {outdir}")
ctx.run(f"cp {outputitem['output']} {outdir}/")
outfiles.append(outputitem['output'])
count += 1

if count == 0:
raise Exit(message="no build outputs captured")
ctx.run(f"tar -C {stagedir} -cJf {absdest} .")

outfiles.sort()
for outfile in outfiles:
ctx.run(f"sha256sum {outfile} >> {absdest}.sum")
Loading