From 312d6a03138fd55c4e79c554313d21abfd3716ac Mon Sep 17 00:00:00 2001 From: Garrett Beaty Date: Tue, 26 Aug 2025 15:47:55 -0700 Subject: [PATCH] Correctly accumulate gs upload URLs https://crrev.com/c/6796221 added a gsutil_urls output property that provides the URLs of uploads to Google storage that were performed by the build. It attempts to accumulate the URLs by updating a dictionary on the result object's properties, but the properties on a step's results object is empty when created, so it was just overriding the property each time with a single element dict. This change keeps the dict on the API object and updates it when an upload is performed so that the final value includes all of the URLs produced by the build. Change-Id: I6681ca7c137969cbef58e09ce24d0605155d2c3e Recipe-Nontrivial-Roll: build Recipe-Nontrivial-Roll: build_internal Recipe-Nontrivial-Roll: chrome_release Recipe-Nontrivial-Roll: chromiumos Recipe-Nontrivial-Roll: infra Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6880970 Commit-Queue: Robbie Iannucci Reviewed-by: Ben Pastene Reviewed-by: Robbie Iannucci Auto-Submit: Garrett Beaty --- recipes/README.recipes.md | 6 +++--- recipes/recipe_modules/gsutil/api.py | 6 +++--- .../recipe_modules/gsutil/examples/full.expected/basic.json | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 01fd51bd6f..868dbe3f44 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -714,7 +714,7 @@ Generates a Gitiles repo URL. See also parse_repo_url. #### **class [GSUtilApi](/recipes/recipe_modules/gsutil/api.py#10)([RecipeApi][recipe_engine/wkt/RecipeApi]):** -— **def [\_\_call\_\_](/recipes/recipe_modules/gsutil/api.py#21)(self, cmd, name=None, use_retry_wrapper=True, version=None, parallel_upload=False, multithreaded=False, infra_step=True, dry_run=False, \*\*kwargs):** +— **def [\_\_call\_\_](/recipes/recipe_modules/gsutil/api.py#22)(self, cmd, name=None, use_retry_wrapper=True, version=None, parallel_upload=False, multithreaded=False, infra_step=True, dry_run=False, \*\*kwargs):** A step to run arbitrary gsutil commands. @@ -754,7 +754,7 @@ Args: — **def [download\_url](/recipes/recipe_modules/gsutil/api.py#128)(self, url, dest, args=None, \*\*kwargs):** -  **@property**
— **def [gsutil\_py\_path](/recipes/recipe_modules/gsutil/api.py#17)(self):** +  **@property**
— **def [gsutil\_py\_path](/recipes/recipe_modules/gsutil/api.py#18)(self):** — **def [list](/recipes/recipe_modules/gsutil/api.py#168)(self, url, args=None, \*\*kwargs):** @@ -764,7 +764,7 @@ Args: — **def [stat](/recipes/recipe_modules/gsutil/api.py#142)(self, url, args=None, \*\*kwargs):** -— **def [upload](/recipes/recipe_modules/gsutil/api.py#98)(self, source, bucket, dest, args=None, link_name='gsutil.upload', metadata=None, unauthenticated_url=False, \*\*kwargs):** +— **def [upload](/recipes/recipe_modules/gsutil/api.py#99)(self, source, bucket, dest, args=None, link_name='gsutil.upload', metadata=None, unauthenticated_url=False, \*\*kwargs):** ### *recipe_modules* / [osx\_sdk](/recipes/recipe_modules/osx_sdk) [DEPS](/recipes/recipe_modules/osx_sdk/__init__.py#6): [recipe\_engine/cipd][recipe_engine/recipe_modules/cipd], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step], [recipe\_engine/version][recipe_engine/recipe_modules/version] diff --git a/recipes/recipe_modules/gsutil/api.py b/recipes/recipe_modules/gsutil/api.py index 3c4a4d405d..acdb70ac59 100644 --- a/recipes/recipe_modules/gsutil/api.py +++ b/recipes/recipe_modules/gsutil/api.py @@ -13,6 +13,7 @@ class GSUtilApi(recipe_api.RecipeApi): super(GSUtilApi, self).__init__(*args, **kwargs) self._boto_config_path = env_properties.BOTO_CONFIG self._boto_path = env_properties.BOTO_PATH + self._upload_urls = {} @property def gsutil_py_path(self): @@ -113,9 +114,8 @@ class GSUtilApi(recipe_api.RecipeApi): is_directory=is_dir, is_anonymous=unauthenticated_url) result.presentation.links[link_name] = link - if 'gsutil_urls' not in result.presentation.properties: - result.presentation.properties['gsutil_urls'] = {} - result.presentation.properties['gsutil_urls'][result.name] = full_dest + self._upload_urls[result.name] = full_dest + result.presentation.properties['gsutil_urls'] = self._upload_urls return result def download(self, bucket, source, dest, args=None, **kwargs): diff --git a/recipes/recipe_modules/gsutil/examples/full.expected/basic.json b/recipes/recipe_modules/gsutil/examples/full.expected/basic.json index 40e99f1634..faa36894ee 100644 --- a/recipes/recipe_modules/gsutil/examples/full.expected/basic.json +++ b/recipes/recipe_modules/gsutil/examples/full.expected/basic.json @@ -51,7 +51,7 @@ "name": "gsutil upload (2)", "~followup_annotations": [ "@@@STEP_LINK@gsutil.upload@https://storage.googleapis.com/example/some/random/path/to/boom@@@", - "@@@SET_BUILD_PROPERTY@gsutil_urls@{\"gsutil upload (2)\": \"gs://example/some/random/path/to/boom\"}@@@" + "@@@SET_BUILD_PROPERTY@gsutil_urls@{\"gsutil upload\": \"gs://example/some/random/path/to/boom\", \"gsutil upload (2)\": \"gs://example/some/random/path/to/boom\"}@@@" ] }, { @@ -71,7 +71,7 @@ "name": "gsutil upload -r", "~followup_annotations": [ "@@@STEP_LINK@gsutil.upload@https://console.cloud.google.com/storage/browser/example/some/random/path@@@", - "@@@SET_BUILD_PROPERTY@gsutil_urls@{\"gsutil upload -r\": \"gs://example/some/random/path\"}@@@" + "@@@SET_BUILD_PROPERTY@gsutil_urls@{\"gsutil upload\": \"gs://example/some/random/path/to/boom\", \"gsutil upload (2)\": \"gs://example/some/random/path/to/boom\", \"gsutil upload -r\": \"gs://example/some/random/path\"}@@@" ] }, { @@ -91,7 +91,7 @@ "name": "gsutil upload --recursive", "~followup_annotations": [ "@@@STEP_LINK@gsutil.upload@https://console.cloud.google.com/storage/browser/example/some/other/random/path@@@", - "@@@SET_BUILD_PROPERTY@gsutil_urls@{\"gsutil upload --recursive\": \"gs://example/some/other/random/path\"}@@@" + "@@@SET_BUILD_PROPERTY@gsutil_urls@{\"gsutil upload\": \"gs://example/some/random/path/to/boom\", \"gsutil upload (2)\": \"gs://example/some/random/path/to/boom\", \"gsutil upload --recursive\": \"gs://example/some/other/random/path\", \"gsutil upload -r\": \"gs://example/some/random/path\"}@@@" ] }, {