Skip to content

Commit

Permalink
Fix base image builds.
Browse files Browse the repository at this point in the history
Fixes #7650.
  • Loading branch information
oliverchang committed May 2, 2022
1 parent 9b1534c commit 27b7aef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
9 changes: 7 additions & 2 deletions infra/build/functions/base_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,13 @@ def run_build(steps, images, tags=None, build_version=MAJOR_TAG):
body_overrides = {
'images': images + [f'{image}:{build_version}' for image in images]
}
return build_lib.run_build(steps, credentials, BASE_PROJECT, body_overrides,
tags)
return build_lib.run_build(steps,
credentials,
BASE_PROJECT,
TIMEOUT,
body_overrides,
tags,
use_build_pool=False)


def base_builder(event, context):
Expand Down
19 changes: 13 additions & 6 deletions infra/build/functions/build_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,9 @@
supported_architectures=['x86_64']),
}

BUILDPOOL_NAME = os.getenv(
OSS_FUZZ_BUILDPOOL_NAME = os.getenv(
'GCB_BUILDPOOL_NAME', 'projects/oss-fuzz/locations/us-central1/'
'workerPools/buildpool')
DEFAULT_GCB_OPTIONS = {'pool': {'name': BUILDPOOL_NAME}}

US_CENTRAL_CLIENT_OPTIONS = ClientOptions(
api_endpoint='https://us-central1-cloudbuild.googleapis.com/')
Expand Down Expand Up @@ -404,12 +403,15 @@ def get_gcb_url(build_id, cloud_project='oss-fuzz'):
f'?project={cloud_project}')


def get_build_body(steps, timeout, body_overrides, tags):
def get_build_body(steps, timeout, body_overrides, tags, use_build_pool=True):
"""Helper function to create a build from |steps|."""
if 'GCB_OPTIONS' in os.environ:
options = yaml.safe_load(os.environ['GCB_OPTIONS'])
else:
options = DEFAULT_GCB_OPTIONS
options = {}

if use_build_pool:
options['pool'] = {'name': OSS_FUZZ_BUILDPOOL_NAME}

build_body = {
'steps': steps,
Expand All @@ -432,10 +434,15 @@ def run_build( # pylint: disable=too-many-arguments
cloud_project,
timeout,
body_overrides=None,
tags=None):
tags=None,
use_build_pool=True):
"""Runs the build."""

build_body = get_build_body(steps, timeout, body_overrides, tags)
build_body = get_build_body(steps,
timeout,
body_overrides,
tags,
use_build_pool=use_build_pool)

cloudbuild = cloud_build('cloudbuild',
'v1',
Expand Down

0 comments on commit 27b7aef

Please sign in to comment.