From 473499ba26225c48262ffe29c782817fe64ea9cb Mon Sep 17 00:00:00 2001 From: Chong Gu Date: Fri, 18 Jun 2021 21:21:37 +0000 Subject: [PATCH] [cipd] Add verification-timeout as a passable flag For Fuchsia official builders, we need a way to increase the verification timeout so that our packages are uploaded successfully Bug:1215771 Change-Id: Ie59dc149e2b88864afea1aaf6700a94324593196 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2973226 Commit-Queue: Chong Gu Auto-Submit: Chong Gu Reviewed-by: Dirk Pranke --- recipes/README.recipes.md | 18 +++++++++++------- recipes/recipe_modules/cipd/api.py | 14 +++++++++++--- .../cipd/examples/full.expected/basic.json | 2 ++ .../full.expected/describe-many-instances.json | 2 ++ .../cipd/examples/full.expected/mac64.json | 2 ++ .../cipd/examples/full.expected/win64.json | 2 ++ recipes/recipe_modules/cipd/examples/full.py | 3 ++- 7 files changed, 32 insertions(+), 11 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index aedf86a8c..ea7e9ef46 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -152,7 +152,7 @@ Args: should use when installing this package. If None, defaults to the platform default ('copy' on windows, 'symlink' on everything else). -— **def [create\_from\_pkg](/recipes/recipe_modules/cipd/api.py#332)(self, pkg_def, refs=None, tags=None):** +— **def [create\_from\_pkg](/recipes/recipe_modules/cipd/api.py#340)(self, pkg_def, refs=None, tags=None):** Builds and uploads a package based on a PackageDefinition object. @@ -170,7 +170,7 @@ Returns the JSON 'result' section, e.g.: { "instance_id": "433bfdf86c0bb82d1eee2d1a0473d3709c25d2c4" } -— **def [create\_from\_yaml](/recipes/recipe_modules/cipd/api.py#312)(self, pkg_def, refs=None, tags=None):** +— **def [create\_from\_yaml](/recipes/recipe_modules/cipd/api.py#314)(self, pkg_def, refs=None, tags=None, verification_timeout=None):** Builds and uploads a package based on on-disk YAML package definition file. @@ -182,6 +182,10 @@ Args: refs (list(str)) - A list of ref names to set for the package instance. tags (dict(str, str)) - A map of tag name -> value to set for the package instance. + verification_timeout (str) - Duration string that controls the time to + wait for backend-side package hash + verification. Valid time units are "ns", + "us", "ms", "s", "m", "h". Returns the JSON 'result' section, e.g.: { "package": "infra/tools/cipd/android-amd64", @@ -190,9 +194,9 @@ Returns the JSON 'result' section, e.g.: {   **@property**
— **def [default\_bot\_service\_account\_credentials](/recipes/recipe_modules/cipd/api.py#200)(self):** -— **def [describe](/recipes/recipe_modules/cipd/api.py#439)(self, package_name, version, test_data_refs=None, test_data_tags=None):** +— **def [describe](/recipes/recipe_modules/cipd/api.py#447)(self, package_name, version, test_data_refs=None, test_data_tags=None):** -— **def [ensure](/recipes/recipe_modules/cipd/api.py#354)(self, root, packages):** +— **def [ensure](/recipes/recipe_modules/cipd/api.py#362)(self, root, packages):** Ensures that packages are installed in a given root dir. @@ -221,13 +225,13 @@ parameters will be used. — **def [register](/recipes/recipe_modules/cipd/api.py#264)(self, package_name, package_path, refs=None, tags=None):** -— **def [search](/recipes/recipe_modules/cipd/api.py#421)(self, package_name, tag):** +— **def [search](/recipes/recipe_modules/cipd/api.py#429)(self, package_name, tag):** -— **def [set\_ref](/recipes/recipe_modules/cipd/api.py#401)(self, package_name, version, refs):** +— **def [set\_ref](/recipes/recipe_modules/cipd/api.py#409)(self, package_name, version, refs):** — **def [set\_service\_account\_credentials](/recipes/recipe_modules/cipd/api.py#193)(self, path):** -— **def [set\_tag](/recipes/recipe_modules/cipd/api.py#381)(self, package_name, version, tags):** +— **def [set\_tag](/recipes/recipe_modules/cipd/api.py#389)(self, package_name, version, tags):** ### *recipe_modules* / [depot\_tools](/recipes/recipe_modules/depot_tools) [DEPS](/recipes/recipe_modules/depot_tools/__init__.py#5): [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime] diff --git a/recipes/recipe_modules/cipd/api.py b/recipes/recipe_modules/cipd/api.py index fd0352837..25564148e 100644 --- a/recipes/recipe_modules/cipd/api.py +++ b/recipes/recipe_modules/cipd/api.py @@ -282,7 +282,7 @@ class CIPDApi(recipe_api.RecipeApi): ) def _create(self, pkg_name, pkg_def_file_or_placeholder, - refs=None, tags=None): + refs=None, tags=None, verification_timeout=None): refs = refs or [] tags = tags or {} check_list_type('refs', refs, str) @@ -295,6 +295,8 @@ class CIPDApi(recipe_api.RecipeApi): ] if self._cipd_credentials: cmd.extend(['-service-account-json', self._cipd_credentials]) + if verification_timeout: + cmd.extend(['-verification-timeout', verification_timeout]) for ref in refs: cmd.extend(['-ref', ref]) for tag, value in sorted(tags.items()): @@ -309,7 +311,8 @@ class CIPDApi(recipe_api.RecipeApi): 'https://chrome-infra-packages.appspot.com/p/%(package)s/+/%(instance_id)s' % ret_data) return ret_data - def create_from_yaml(self, pkg_def, refs=None, tags=None): + def create_from_yaml(self, pkg_def, refs=None, tags=None, + verification_timeout=None): """Builds and uploads a package based on on-disk YAML package definition file. @@ -320,6 +323,10 @@ class CIPDApi(recipe_api.RecipeApi): refs (list(str)) - A list of ref names to set for the package instance. tags (dict(str, str)) - A map of tag name -> value to set for the package instance. + verification_timeout (str) - Duration string that controls the time to + wait for backend-side package hash + verification. Valid time units are "ns", + "us", "ms", "s", "m", "h". Returns the JSON 'result' section, e.g.: { "package": "infra/tools/cipd/android-amd64", @@ -327,7 +334,8 @@ class CIPDApi(recipe_api.RecipeApi): } """ check_type('pkg_def', pkg_def, Path) - return self._create(self.m.path.basename(pkg_def), pkg_def, refs, tags) + return self._create(self.m.path.basename(pkg_def), pkg_def, refs, tags, + verification_timeout) def create_from_pkg(self, pkg_def, refs=None, tags=None): """Builds and uploads a package based on a PackageDefinition object. diff --git a/recipes/recipe_modules/cipd/examples/full.expected/basic.json b/recipes/recipe_modules/cipd/examples/full.expected/basic.json index c4393a9a1..f729958b0 100644 --- a/recipes/recipe_modules/cipd/examples/full.expected/basic.json +++ b/recipes/recipe_modules/cipd/examples/full.expected/basic.json @@ -291,6 +291,8 @@ "/path/to/tmp/json", "-service-account-json", "fake-credentials.json", + "-verification-timeout", + "10m", "-ref", "fake-ref-1", "-ref", diff --git a/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json b/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json index 475c804f6..78257d820 100644 --- a/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json +++ b/recipes/recipe_modules/cipd/examples/full.expected/describe-many-instances.json @@ -291,6 +291,8 @@ "/path/to/tmp/json", "-service-account-json", "fake-credentials.json", + "-verification-timeout", + "10m", "-ref", "fake-ref-1", "-ref", diff --git a/recipes/recipe_modules/cipd/examples/full.expected/mac64.json b/recipes/recipe_modules/cipd/examples/full.expected/mac64.json index f5f302984..1896acead 100644 --- a/recipes/recipe_modules/cipd/examples/full.expected/mac64.json +++ b/recipes/recipe_modules/cipd/examples/full.expected/mac64.json @@ -291,6 +291,8 @@ "/path/to/tmp/json", "-service-account-json", "fake-credentials.json", + "-verification-timeout", + "10m", "-ref", "fake-ref-1", "-ref", diff --git a/recipes/recipe_modules/cipd/examples/full.expected/win64.json b/recipes/recipe_modules/cipd/examples/full.expected/win64.json index aec4e5e0f..9a5314c58 100644 --- a/recipes/recipe_modules/cipd/examples/full.expected/win64.json +++ b/recipes/recipe_modules/cipd/examples/full.expected/win64.json @@ -291,6 +291,8 @@ "/path/to/tmp/json", "-service-account-json", "fake-credentials.json", + "-verification-timeout", + "10m", "-ref", "fake-ref-1", "-ref", diff --git a/recipes/recipe_modules/cipd/examples/full.py b/recipes/recipe_modules/cipd/examples/full.py index 0a1abbbd1..1a2814a6b 100644 --- a/recipes/recipe_modules/cipd/examples/full.py +++ b/recipes/recipe_modules/cipd/examples/full.py @@ -83,7 +83,8 @@ def RunSteps(api, use_pkg, pkg_files, pkg_dirs, ver_files, install_mode): api.cipd.create_from_yaml(api.path['start_dir'].join('fake-package.yaml'), refs=['fake-ref-1', 'fake-ref-2'], tags={'fake_tag_1': 'fake_value_1', - 'fake_tag_2': 'fake_value_2'}) + 'fake_tag_2': 'fake_value_2'}, + verification_timeout='10m') # Set tag or ref of an already existing package.