Skip to content

Commit

Permalink
Revert "Save docker images for C/C++ (#12831)"
Browse files Browse the repository at this point in the history
This reverts commit 02c5dc9.
  • Loading branch information
DavidKorczynski authored Dec 20, 2024
1 parent e17999e commit 2ea92de
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 53 deletions.
36 changes: 9 additions & 27 deletions infra/build/functions/build_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ def get_docker_build_step(image_names,
'name': DOCKER_TOOL_IMAGE,
'args': args,
'dir': directory,
'id': f'build-{architecture}',
}
# Handle buildkit args
# Note that we mutate "args" after making it a value in step.
Expand Down Expand Up @@ -463,11 +462,10 @@ def get_project_image_steps( # pylint: disable=too-many-arguments
steps.extend(get_pull_test_images_steps(config.test_image_suffix))
src_root = 'oss-fuzz' if not experiment else '.'

docker_build_step = get_docker_build_step(
[image, _get_unsafe_name(name)],
os.path.join('projects', name),
src_root=src_root,
cache_image=cache_image)
docker_build_step = get_docker_build_step([image],
os.path.join('projects', name),
src_root=src_root,
cache_image=cache_image)
steps.append(docker_build_step)
if srcmap:
srcmap_step_id = get_srcmap_step_id()
Expand All @@ -479,7 +477,7 @@ def get_project_image_steps( # pylint: disable=too-many-arguments
],
'env': [
'OSSFUZZ_REVISION=$REVISION_ID',
f'FUZZING_LANGUAGE={language}',
'FUZZING_LANGUAGE=%s' % language,
],
'id': srcmap_step_id
}])
Expand All @@ -500,31 +498,15 @@ def get_project_image_steps( # pylint: disable=too-many-arguments
'args': ['buildx', 'use', builder_name]
},
])
docker_build_arm_step = get_docker_build_step(
[image, _get_unsafe_name(name)],
os.path.join('projects', name),
architecture=_ARM64)
docker_build_arm_step = get_docker_build_step([image],
os.path.join(
'projects', name),
architecture=_ARM64)
steps.append(docker_build_arm_step)

if (not experiment and not config.testing and
config.build_type == 'fuzzing' and language in ('c', 'c++')):
# Push so that historical bugs are reproducible.
push_step = {
'name': 'gcr.io/cloud-builders/docker',
'args': ['push', _get_unsafe_name(name)],
'id': 'push-image',
'waitFor': [docker_build_step['id']],
'allowFailure': True
}
steps.append(push_step)

return steps


def _get_unsafe_name(name):
return f'us-central1-docker.pkg.dev/oss-fuzz/unsafe/{name}'


def get_logs_url(build_id):
"""Returns url that displays the build logs."""
return (
Expand Down
11 changes: 6 additions & 5 deletions infra/build/functions/build_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
Usage: build_project.py <project_dir>
"""

from __future__ import print_function

import argparse
from dataclasses import dataclass
import datetime
Expand Down Expand Up @@ -75,7 +77,6 @@ class Config:
experiment: bool = False
# TODO(ochang): This should be different per engine+sanitizer combination.
upload_build_logs: str = None
build_type: str = None


WORKDIR_REGEX = re.compile(r'\s*WORKDIR\s*([^\s]+)')
Expand Down Expand Up @@ -475,6 +476,7 @@ def get_build_steps_for_project(project,
upload_steps = get_upload_steps(project, build, timestamp,
config.testing)
build_steps.extend(upload_steps)

return build_steps


Expand Down Expand Up @@ -627,16 +629,15 @@ def get_args(description):
return parser.parse_args()


def create_config(args, build_type):
def create_config_from_commandline(args):
"""Create a Config object from parsed command line |args|."""
upload = not args.experiment
return Config(testing=args.testing,
test_image_suffix=args.test_image_suffix,
branch=args.branch,
parallel=args.parallel,
upload=upload,
experiment=args.experiment,
build_type=build_type)
experiment=args.experiment)


def build_script_main(script_description, get_build_steps_func, build_type):
Expand All @@ -649,7 +650,7 @@ def build_script_main(script_description, get_build_steps_func, build_type):

credentials = oauth2client.client.GoogleCredentials.get_application_default()
error = False
config = create_config(args, build_type)
config = create_config_from_commandline(args)
for project_name in args.projects:
logging.info('Getting steps for: "%s".', project_name)
try:
Expand Down
10 changes: 2 additions & 8 deletions infra/build/functions/test_data/expected_build_steps.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
"build",
"--tag",
"gcr.io/oss-fuzz/test-project",
"--tag",
"us-central1-docker.pkg.dev/oss-fuzz/unsafe/test-project",
"."
],
"dir": "oss-fuzz/projects/test-project",
"id": "build-x86_64"
"dir": "oss-fuzz/projects/test-project"
},
{
"name": "gcr.io/oss-fuzz/test-project",
Expand Down Expand Up @@ -71,12 +68,9 @@
"--load",
"--tag",
"gcr.io/oss-fuzz/test-project-aarch64",
"--tag",
"us-central1-docker.pkg.dev/oss-fuzz/unsafe/test-project-aarch64",
"."
],
"dir": "oss-fuzz/projects/test-project",
"id": "build-aarch64"
"dir": "oss-fuzz/projects/test-project"
},
{
"name": "gcr.io/cloud-builders/docker",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
"args": [
"build",
"--tag",
"gcr.io/oss-fuzz/test-project",
"--tag",
"us-central1-docker.pkg.dev/oss-fuzz/unsafe/test-project",
"gcr.io/oss-fuzz/test-project",
"."
],
"dir": "oss-fuzz/projects/test-project",
"id": "build-x86_64"
"dir": "oss-fuzz/projects/test-project"
},
{
"name": "gcr.io/oss-fuzz/test-project",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,9 @@
"build",
"--tag",
"gcr.io/oss-fuzz/test-project",
"--tag",
"us-central1-docker.pkg.dev/oss-fuzz/unsafe/test-project",
"."
],
"dir": "oss-fuzz/projects/test-project",
"id": "build-x86_64"
"dir": "oss-fuzz/projects/test-project"
},
{
"name": "gcr.io/oss-fuzz/test-project",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,9 @@
"build",
"--tag",
"gcr.io/oss-fuzz/skcms",
"--tag",
"us-central1-docker.pkg.dev/oss-fuzz/unsafe/skcms",
"."
],
"dir": "oss-fuzz/projects/skcms",
"id": "build-x86_64"
"dir": "oss-fuzz/projects/skcms"
},
{
"name": "gcr.io/oss-fuzz/skcms",
Expand Down

0 comments on commit 2ea92de

Please sign in to comment.