Skip to content

Commit

Permalink
Customize cloud build region
Browse files Browse the repository at this point in the history
  • Loading branch information
DonggeLiu committed Oct 15, 2024
1 parent 9e6a8de commit 7130c92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion infra/build/build_status/update_build_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def __init__(self):
'v1',
credentials=self._credentials,
cache_discovery=False,
client_options=build_lib.US_CENTRAL_CLIENT_OPTIONS)
client_options=build_lib.REGIONAL_CLIENT_OPTIONS)
self._cloudbuilds = [self._global_cloudbuild, self._central_cloudbuild]
self._swapped = False

Expand Down
11 changes: 6 additions & 5 deletions infra/build/functions/build_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@
'GCB_BUILDPOOL_NAME', 'projects/oss-fuzz/locations/us-central1/'
'workerPools/buildpool-experiments')

US_CENTRAL_CLIENT_OPTIONS = google.api_core.client_options.ClientOptions(
api_endpoint='https://us-central1-cloudbuild.googleapis.com/')
CLOUD_BUILD_LOCATION = os.getenv('CLOUD_BUILD_LOCATIONS', 'us-central1')
REGIONAL_CLIENT_OPTIONS = google.api_core.client_options.ClientOptions(
api_endpoint=f'https://{CLOUD_BUILD_LOCATION}-cloudbuild.googleapis.com/')

DOCKER_TOOL_IMAGE = 'gcr.io/cloud-builders/docker'

Expand Down Expand Up @@ -603,7 +604,7 @@ def run_build( # pylint: disable=too-many-arguments, too-many-locals
'v1',
credentials=credentials,
cache_discovery=False,
client_options=US_CENTRAL_CLIENT_OPTIONS)
client_options=REGIONAL_CLIENT_OPTIONS)

build_info = cloudbuild.projects().builds().create(projectId=cloud_project,
body=build_body).execute()
Expand All @@ -621,7 +622,7 @@ def wait_for_build(build_id, credentials, cloud_project):
'v1',
credentials=credentials,
cache_discovery=False,
client_options=US_CENTRAL_CLIENT_OPTIONS)
client_options=REGIONAL_CLIENT_OPTIONS)

while True:
try:
Expand All @@ -643,6 +644,6 @@ def cancel_build(build_id, credentials, cloud_project):
'v1',
credentials=credentials,
cache_discovery=False,
client_options=US_CENTRAL_CLIENT_OPTIONS)
client_options=REGIONAL_CLIENT_OPTIONS)
cloudbuild.projects().builds().cancel(projectId=cloud_project,
id=build_id).execute()
2 changes: 1 addition & 1 deletion infra/build/functions/trial_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def wait_on_builds(build_ids, credentials, cloud_project, end_time): # pylint:
'v1',
credentials=credentials,
cache_discovery=False,
client_options=build_lib.US_CENTRAL_CLIENT_OPTIONS)
client_options=build_lib.REGIONAL_CLIENT_OPTIONS)
cloudbuild_api = cloudbuild.projects().builds() # pylint: disable=no-member

wait_builds = build_ids.copy()
Expand Down

0 comments on commit 7130c92

Please sign in to comment.