Skip to content

[History Server] Anchor the GCS GetContent search at the configured root dir - #5077

Open
stantheman0128 wants to merge 1 commit into
ray-project:masterfrom
stantheman0128:fix/gcs-getcontent-rootdir
Open

[History Server] Anchor the GCS GetContent search at the configured root dir#5077
stantheman0128 wants to merge 1 commit into
ray-project:masterfrom
stantheman0128:fix/gcs-getcontent-rootdir

Conversation

@stantheman0128

Copy link
Copy Markdown

Summary

The GCS history-server backend searched for log objects with an unanchored MatchGlob (**/<cluster>*/**/<file>). GCS treats ** as crossing /, so the pattern was not rooted at RootDir even though ListFiles and List in the same handler already join paths under h.RootDir.

This change extracts contentMatchGlob and anchors the search at the configured root directory, matching the s3/azureblob/aliyunoss backends.

AI disclosure

AI-assisted patch; human-reviewed by Stan Shih (stantheman0128) before publish.

Verification / Evidence

cd historyserver
go test ./pkg/storage/gcs/... -count=1 -v
# TestContentMatchGlobIsRooted PASS (rooted / no-root / trimmed-slash cases)
# TestGetContent PASS (existing fake-gcs-server happy path still green)

What was not tested

  • Real Google Cloud Storage bucket with two root directories under one bucket (no GCS credentials in this environment).
  • End-to-end MatchGlob behaviour against fake-gcs-server: v1.53.1 does not implement matchGlob (grep shows zero hits), so the glob contract is asserted on contentMatchGlob directly instead of an integration test that would fail for the wrong reason.

Related context: #5075 adds s3/azureblob GetContent path tests; this PR fixes the GCS production path.

…oot dir

GetContent searched with the glob "**/<cluster>*/**/<file>". Per the GCS
docs, "**" matches zero or more characters including "/", so a leading
"**/" places no constraint on the prefix at all. The search therefore
ignores RootDir, while ListFiles and List in the same handler both build
their prefixes with path.Join(h.RootDir, ...).

On a bucket holding more than one root dir, for example two history
server deployments sharing it, the search can match an object under a
different root dir and GetContent returns whichever one the iterator
yields first.

Anchor the pattern at RootDir. An empty RootDir keeps the previous
unanchored pattern, so deployments that do not set one are unaffected.

The pattern is built by a small helper so it can be asserted directly:
fake-gcs-server does not implement matchGlob, so no test in this package
can observe what a pattern actually selects. That also means the existing
TestGetContent never exercised the glob; it passes because its bucket
holds a single object.
@machichima

Copy link
Copy Markdown
Collaborator

cc @chiayi

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