Skip to content

chore: Migrate from gsutil to gcloud storage#2183

Open
tiffanny29631 wants to merge 1 commit into
GoogleContainerTools:mainfrom
tiffanny29631:gsutil
Open

chore: Migrate from gsutil to gcloud storage#2183
tiffanny29631 wants to merge 1 commit into
GoogleContainerTools:mainfrom
tiffanny29631:gsutil

Conversation

@tiffanny29631
Copy link
Copy Markdown
Contributor

No description provided.

@google-oss-prow
Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@google-oss-prow
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from tiffanny29631. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow Bot requested review from cowsking and janetkuo May 29, 2026 18:16
@tiffanny29631 tiffanny29631 changed the title chore: Migrated from gsutil to gcloud storage chore: Migrate from gsutil to gcloud storage May 29, 2026
@tiffanny29631
Copy link
Copy Markdown
Contributor Author

/test all

@tiffanny29631 tiffanny29631 removed the request for review from janetkuo May 29, 2026 18:16
Copy link
Copy Markdown
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 migrates the codebase from using gsutil to gcloud storage for Google Cloud Storage operations across build environments, CI/CD configurations, documentation, and helper scripts. The review feedback highlights efficiency issues in scripts/update-component-image.sh where the migration to gcloud storage ls lacks prefix filtering and directory-only listing, which could lead to listing all objects recursively and cause performance degradation. Suggestions are provided to restore the prefix filter and use the -d flag.

Comment on lines +104 to 107
if [ "${QUERY_TYPE}" == "gcloud-storage" ]; then
FILTER=""
GREP_PATTERN="^${BASE_VERSION%-gke.*}"
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Setting FILTER to empty for gcloud-storage queries causes gcloud storage ls to list all objects/directories under GCS_PATH without any prefix filtering. This is highly inefficient if there are many tags. Instead, we should retain the prefix filter and use gcloud storage ls -d with the filter to query only matching directories, similar to how gsutil ls -d was used.

Suggested change
if [ "${QUERY_TYPE}" == "gcloud-storage" ]; then
FILTER=""
GREP_PATTERN="^${BASE_VERSION%-gke.*}"
fi
if [ "${QUERY_TYPE}" == "gcloud-storage" ]; then
FILTER="${BASE_VERSION%-gke.*}*"
GREP_PATTERN="^${BASE_VERSION%-gke.*}"
fi

Comment on lines 119 to 121
# Query GCS and strip path/trailing slash
LATEST_TAG=$(gsutil ls -d "${GCS_PATH}${FILTER}/" | sed "s|${GCS_PATH}||; s|/||" | grep "${GREP_PATTERN}" | sort -V | tail -n 1)
LATEST_TAG=$(gcloud storage ls "${GCS_PATH}" | sed "s|${GCS_PATH}||; s|/||" | grep "${GREP_PATTERN}" | sort -V | tail -n 1)
fi
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Use gcloud storage ls -d (or --directories) with the ${FILTER} suffix to avoid listing the entire directory recursively or listing all tags. This matches the behavior of the original gsutil ls -d command and is much more efficient.

Suggested change
# Query GCS and strip path/trailing slash
LATEST_TAG=$(gsutil ls -d "${GCS_PATH}${FILTER}/" | sed "s|${GCS_PATH}||; s|/||" | grep "${GREP_PATTERN}" | sort -V | tail -n 1)
LATEST_TAG=$(gcloud storage ls "${GCS_PATH}" | sed "s|${GCS_PATH}||; s|/||" | grep "${GREP_PATTERN}" | sort -V | tail -n 1)
fi
# Query GCS and strip path/trailing slash
LATEST_TAG=$(gcloud storage ls -d "${GCS_PATH}${FILTER}" | sed "s|${GCS_PATH}||; s|/||" | grep "${GREP_PATTERN}" | sort -V | tail -n 1)

@tiffanny29631 tiffanny29631 marked this pull request as ready for review May 29, 2026 20:16
@google-oss-prow google-oss-prow Bot requested a review from janetkuo May 29, 2026 20:16
@tiffanny29631
Copy link
Copy Markdown
Contributor Author

Replaces #2118

@tiffanny29631 tiffanny29631 requested review from Camila-B and removed request for janetkuo May 29, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant