Skip to content

chore: Migrate gsutil usage to gcloud storage#1378

Open
bhandarivijay-png wants to merge 1 commit intoGoogleCloudDataproc:mainfrom
bhandarivijay-png:ai-gsutil-migration-0999534fadae4cd69af822d1f4778a50
Open

chore: Migrate gsutil usage to gcloud storage#1378
bhandarivijay-png wants to merge 1 commit intoGoogleCloudDataproc:mainfrom
bhandarivijay-png:ai-gsutil-migration-0999534fadae4cd69af822d1f4778a50

Conversation

@bhandarivijay-png
Copy link

Automated: Migrate {target_path} from gsutil to gcloud storage

This CL is part of the on going effort to migrate from the legacy gsutil tool to the new and improved gcloud storage command-line interface.
gcloud storage is the recommended and modern tool for interacting with Google Cloud Storage, offering better performance, unified authentication, and a more consistent command structure with other gcloud components. 🚀

Automation Details

This change was generated automatically by an agent that targets users of gsutil.
The transformations applied are based on the gsutil to gcloud storage migration guide.

⚠️ Action Required: Please Review and Test Carefully

While we have based the automation on the migration guide, every use case is unique.
It is crucial that you thoroughly test these changes in environments appropriate to your use-case before merging.
Be aware of potential differences between gsutil and gcloud storage that could impact your workflows.
For instance, the structure of command output may have changed, requiring updates to any scripts that parse it. Similarly, command behavior can differ subtly; the gcloud storage rsync command has a different file deletion logic than gsutil rsync, which could lead to unintended file deletions.

Our migration guides can help guide you through a list of mappings and some notable differences between the two tools.

Standard presubmit tests are run as part of this CL's workflow. If you need to target an additional test workflow or require assistance with testing, please let us know.

Please verify that all your Cloud Storage operations continue to work as expected to avoid any potential disruptions in production.

Support and Collaboration

The GCS CLI team is here to help! If you encounter any issues, have a complex use case that this automated change doesn't cover, or face any other blockers, please don't hesitate to reach out.
We are happy to work with you to test and adjust these changes as needed.

Contact: gcs-cli-hyd@google.com

We appreciate your partnership in this important migration effort!

#gsutil-migration

@bhandarivijay-png
Copy link
Author

Hi @vinayakumarb, Can we get your review on this PR? Thanks!

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request systematically updates existing scripts and documentation to utilize the modern gcloud storage command-line interface instead of the legacy gsutil tool. This migration aligns with Google Cloud's recommendation for improved performance, unified authentication, and a more consistent command structure, ensuring that all interactions with Google Cloud Storage leverage the latest tooling.

Highlights

  • Command Migration: Migrated all instances of gsutil commands to their gcloud storage equivalents across various scripts and documentation files.
  • Recursive Copy: Replaced gsutil -m cp -r with gcloud storage cp --recursive for copying directories.
  • Preserve POSIX Attributes: Updated gsutil cp -P to gcloud storage cp --preserve-posix to maintain file attributes during copy operations.
  • Object Status Check: Replaced gsutil -q stat with gcloud storage objects list --stat --fetch-encrypted-object-hashes for checking object status.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • README.md
    • Replaced gsutil cp with gcloud storage cp for copying files.
  • alluxio/alluxio.sh
    • Updated gsutil cp to gcloud storage cp within the download_file function.
  • beam/README.md
    • Replaced gsutil cp with gcloud storage cp in the example for uploading JARs.
  • beam/beam.sh
    • Updated gsutil cp to gcloud storage cp in the download_snapshot function.
  • conda/README.md
    • Replaced gsutil -m cp -r with gcloud storage cp --recursive for copying bootstrap and install scripts.
    • Updated gsutil -m cp -r to gcloud storage cp --recursive for downloading conda environment YAML files.
  • connectors/connectors.sh
    • Replaced gsutil cp -P with gcloud storage cp --preserve-posix for updating connector URLs.
  • dask/README.md
    • Updated gsutil cp to gcloud storage cp in the example for downloading Python files via SSH.
  • hbase/hbase.sh
    • Replaced gsutil cp with gcloud storage cp for copying HBase keytabs.
    • Updated gsutil -q stat to gcloud storage objects list --stat --fetch-encrypted-object-hashes for checking success file status.
  • hive-llap/llap.sh
    • Replaced gsutil cp with gcloud storage cp for downloading initialization actions.
  • mlvm/mlvm.sh
    • Updated gsutil -m rsync -r to gcloud storage rsync --recursive for synchronizing GPU, Rapids, and Dask initialization actions.
    • Replaced gsutil cp with gcloud storage cp for installing Spark BigQuery connectors.
Activity
  • No human activity has occurred on this pull request yet, as it was automatically generated.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request automates the migration from gsutil to gcloud storage. The changes are mostly correct replacements. I've identified a couple of areas where the automated translation could be improved for clarity and to better match the original behavior, particularly in example commands in documentation and in a shell script checking for object existence.

Comment on lines +80 to +81
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/bootstrap-conda.sh .
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/install-conda-env.sh .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The --recursive flag is unnecessary when copying single files. Its use here could be confusing for users. For clarity, it's better to remove it.

Suggested change
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/bootstrap-conda.sh .
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/install-conda-env.sh .
gcloud storage cp gs://goog-dataproc-initialization-actions-${REGION}/conda/bootstrap-conda.sh .
gcloud storage cp gs://goog-dataproc-initialization-actions-${REGION}/conda/install-conda-env.sh .

Comment on lines +103 to +105
gcloud storage cp --recursive $CONDA_ENV_YAML_GSC_LOC $CONDA_ENV_YAML_PATH
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/bootstrap-conda.sh .
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/install-conda-env.sh .
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The --recursive flag is unnecessary when copying single files. Its use here could be confusing for users. For clarity, it's better to remove it.

Suggested change
gcloud storage cp --recursive $CONDA_ENV_YAML_GSC_LOC $CONDA_ENV_YAML_PATH
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/bootstrap-conda.sh .
gcloud storage cp --recursive gs://goog-dataproc-initialization-actions-${REGION}/conda/install-conda-env.sh .
gcloud storage cp $CONDA_ENV_YAML_GSC_LOC $CONDA_ENV_YAML_PATH
gcloud storage cp gs://goog-dataproc-initialization-actions-${REGION}/conda/bootstrap-conda.sh .
gcloud storage cp gs://goog-dataproc-initialization-actions-${REGION}/conda/install-conda-env.sh .

sleep 1
success=$(
gsutil -q stat "${KEYTAB_BUCKET}/keytabs/${CLUSTER_NAME}/_success"
gcloud storage objects list --stat --fetch-encrypted-object-hashes "${KEYTAB_BUCKET}/keytabs/${CLUSTER_NAME}/_success"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The original gsutil -q stat command was quiet. The replacement gcloud storage objects list will print an error to stderr if the object doesn't exist, causing log noise inside this while loop. A more accurate replacement for checking object existence is gcloud storage objects describe, with its output redirected to /dev/null to replicate the quiet behavior. The --fetch-encrypted-object-hashes flag is also unnecessary.

Suggested change
gcloud storage objects list --stat --fetch-encrypted-object-hashes "${KEYTAB_BUCKET}/keytabs/${CLUSTER_NAME}/_success"
gcloud storage objects describe "${KEYTAB_BUCKET}/keytabs/${CLUSTER_NAME}/_success" &> /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant