diff --git a/scripts/gha/gcs_uploader.py b/scripts/gha/gcs_uploader.py index d12f167991..f8a98de0c0 100644 --- a/scripts/gha/gcs_uploader.py +++ b/scripts/gha/gcs_uploader.py @@ -85,11 +85,11 @@ def main(argv): for artifact in artifacts: dest = _local_path_to_gcs_uri(gcs_prefix, artifact, testapp_dir) logging.info("Creating %s", dest) - subprocess.run([gcs.GSUTIL, "cp", artifact, dest], check=True) + subprocess.run([gcs.GCLOUD, "storage", "cp", artifact, dest], check=True) logging.info("Finished uploading to %s", gcs_prefix) logging.info( - "Use 'gsutil cp ' to copy an artifact locally.\n" - "Use 'gsutil -m cp -r %s ' to copy everything.", gcs_prefix) + "Use 'gcloud storage cp ' to copy an artifact locally.\n" + "Use 'gcloud storage cp --recursive %s ' to copy everything.", gcs_prefix) def _local_path_to_gcs_uri(gcs_prefix, path, testapp_dir): diff --git a/scripts/gha/integration_testing/ftl_gha_validator.py b/scripts/gha/integration_testing/ftl_gha_validator.py index dfa6118ebb..63d400304f 100644 --- a/scripts/gha/integration_testing/ftl_gha_validator.py +++ b/scripts/gha/integration_testing/ftl_gha_validator.py @@ -21,7 +21,7 @@ import re from retry import retry -GSUTIL = shutil.which("gsutil") +GCLOUD = shutil.which("gcloud") def validate(test_summary): if not test_summary: @@ -77,7 +77,7 @@ def _get_testapp_log_text_from_gcs(gcs_path): @retry(subprocess.CalledProcessError, tries=10, delay=5, backoff=1.5) def _gcs_list_dir(gcs_path): """Recursively returns a list of contents for a directory on GCS.""" - args = [GSUTIL, "ls", "-r", gcs_path] + args = [GCLOUD, "storage", "ls", "--recursive", gcs_path] logging.info("Listing GCS contents: %s", " ".join(args)) try: result = subprocess.run(args=args, capture_output=True, text=True, check=True) @@ -97,7 +97,7 @@ def _gcs_list_dir(gcs_path): @retry(subprocess.CalledProcessError, tries=10, delay=5, backoff=1.5) def _gcs_read_file(gcs_path): """Extracts the contents of a file on GCS.""" - args = [GSUTIL, "cat", gcs_path] + args = [GCLOUD, "storage", "cat", gcs_path] logging.info("Reading GCS file: %s", " ".join(args)) try: result = subprocess.run(args=args, capture_output=True, text=True, check=True) diff --git a/scripts/gha/integration_testing/gcs.py b/scripts/gha/integration_testing/gcs.py index b17adea8d5..bfd8cca60c 100644 --- a/scripts/gha/integration_testing/gcs.py +++ b/scripts/gha/integration_testing/gcs.py @@ -28,7 +28,6 @@ # Note: this kind of thing (among others) could likely be simplified by using # the gCloud Python API instead of the command line tools. GCLOUD = shutil.which("gcloud") -GSUTIL = shutil.which("gsutil") PROJECT_ID = "games-auto-release-testing" @@ -56,7 +55,7 @@ def get_unique_gcs_id(): def relative_path_to_gs_uri(path): - """Converts a relative GCS path to a GS URI understood by gsutil. + """Converts a relative GCS path to a GS URI understood by gcloud storage. This will prepend the gs prefix and project id to the path, i.e. path -> gs:///results_dir @@ -93,21 +92,18 @@ def authorize_gcs(key_file): def get_gsutil_tips(): """Returns a human readable string with tips on accessing a GCS bucket.""" return "\n".join(( - "GCS Advice: Install the Google Cloud SDK to access the gsutil tool.", - "Use 'gsutil ls ' to list contents of a directory on GCS.", - "Use 'gsutil cp ' to copy an artifact.", - "Use 'gsutil -m cp -r ' to copy a directory." + "GCS Advice: Install the Google Cloud SDK to access the gcloud storage tool.", + "Use 'gcloud storage ls ' to list contents of a directory on GCS.", + "Use 'gcloud storage cp ' to copy an artifact.", + "Use 'gcloud storage cp --recursive ' to copy a directory." )) def _verify_gcloud_sdk_command_line_tools(): """Verifies the presence of the gCloud SDK's command line tools.""" - logging.info("Looking for gcloud and gsutil tools...") + logging.info("Looking for gcloud tools...") if not GCLOUD: logging.error("gcloud not on path") - if not GSUTIL: - logging.error("gsutil not on path") - if not GCLOUD or not GSUTIL: + if not GCLOUD: raise RuntimeError("Could not find required gCloud SDK tool(s)") subprocess.run([GCLOUD, "version"], check=True) - subprocess.run([GSUTIL, "version"], check=True)