Skip to content

chore: migrate gsutil usage to gcloud storage - #190

Open
gurusai-voleti wants to merge 2 commits into
GoogleCloudDataproc:mainfrom
gurusai-voleti:ai-gsutil-migration-5368a51358504f3b95cf4b74c186bdf8
Open

gurusai-voleti wants to merge 2 commits into
GoogleCloudDataproc:mainfrom
gurusai-voleti:ai-gsutil-migration-5368a51358504f3b95cf4b74c186bdf8

Conversation

@gurusai-voleti

Copy link
Copy Markdown
Contributor

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. 🚀

⚠️ 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.

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 (external guide).

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

@gurusai-voleti

Copy link
Copy Markdown
Contributor Author

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

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

Copy link
Copy Markdown

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 updates various scripts and documentation to use gcloud storage instead of the legacy gsutil tool. Feedback on gcloud/init/gce-proxy-setup.sh highlights that since initialization scripts may run on older Dataproc images, gcloud storage might not be available or fully supported. It is recommended to provide a fallback to gsutil to ensure compatibility across all supported Dataproc image versions.

proxy_ca_pem="${trusted_pem_dir}/proxy_ca.crt"
mkdir -p "${trusted_pem_dir}"
gsutil cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }
gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since this initialization script can run on older Dataproc images (such as 1.5 or 2.0), gcloud storage might not be available or fully supported in the pre-installed Google Cloud SDK version. Additionally, running as root during initialization can sometimes lead to gcloud configuration or authentication issues. Providing a fallback to gsutil ensures compatibility across all supported Dataproc image versions.

Suggested change
gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }
(gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || gsutil cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}") || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }

proxy_ca_pem="${trusted_pem_dir}/proxy_ca.crt"
mkdir -p "${trusted_pem_dir}"
gsutil cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }
gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

Since this initialization script can run on older Dataproc images (such as 1.5 or 2.0), gcloud storage might not be available or fully supported in the pre-installed Google Cloud SDK version. Additionally, running as root during initialization can sometimes lead to gcloud configuration or authentication issues. Providing a fallback to gsutil ensures compatibility across all supported Dataproc image versions.

Suggested change
gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }
(gcloud storage cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}" || gsutil cp "${METADATA_HTTP_PROXY_PEM_URI}" "${proxy_ca_pem}") || { echo "ERROR: Failed to download proxy CA cert from GCS." ; exit 1 ; }

@gurusai-voleti gurusai-voleti changed the title Migrate gsutil usage to gcloud storage chore: migrate gsutil usage to gcloud storage Oct 20, 2026
@gurusai-voleti
gurusai-voleti force-pushed the ai-gsutil-migration-5368a51358504f3b95cf4b74c186bdf8 branch from 4471c62 to 628fe3c Compare October 20, 2026 08:13
@cjac

cjac commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

It looks like you're switching over to gcloud storage from gsutil with the assumption that the user has a sufficiently recent gcloud install. Can you please check if the version of gcloud is recent enough before doing so?

Be sure to cover the use case of gsutil stat and gsutil rsync as well ; we can't just s/gsutil/gcloud storage/ since some of the API doesn't match exactly.

@gurusai-voleti

Copy link
Copy Markdown
Contributor Author

It looks like you're switching over to gcloud storage from gsutil with the assumption that the user has a sufficiently recent gcloud install. Can you please check if the version of gcloud is recent enough before doing so?

Be sure to cover the use case of gsutil stat and gsutil rsync as well ; we can't just s/gsutil/gcloud storage/ since some of the API doesn't match exactly.

this check should be in all files or only in gcloud/init/gce-proxy-setup.sh @cjac

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.

2 participants