Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flytestdlib's stowStore.List for google cloud storage #6098

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions flytestdlib/storage/stow_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (s *StowStore) Head(ctx context.Context, reference DataReference) (Metadata
}

func (s *StowStore) List(ctx context.Context, reference DataReference, maxItems int, cursor Cursor) ([]DataReference, Cursor, error) {
_, containerName, key, err := reference.Split()
protocol, containerName, key, err := reference.Split()
if err != nil {
s.metrics.BadReference.Inc(ctx)
return nil, NewCursorAtEnd(), err
Expand Down Expand Up @@ -291,7 +291,17 @@ func (s *StowStore) List(ctx context.Context, reference DataReference, maxItems
if err == nil {
results := make([]DataReference, len(items))
for index, item := range items {
results[index] = DataReference(item.URL().String())
// We don't use `item.URL()` because e.g. listing a google cloud storage
// bucket `gs://some-bucket/...` will result in items with URLs like
// `google://storage.googleapis.com/download/storage/v1/b/some-bucket/...`
// which subsequently cannot be found by the stow store.

u := url.URL{
Scheme: protocol,
Host: containerName,
Path: item.Name(),
}
results[index] = DataReference(u.String())
Comment on lines +299 to +304
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we fix this in our fork of stow? It looks like we change the scheme here, which is used in gcs implementation of convertToStowItem.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do, overlooked we use a fork of stow 👌

}
if stow.IsCursorEnd(stowCursor) {
cursor = NewCursorAtEnd()
Expand Down
9 changes: 5 additions & 4 deletions flytestdlib/storage/stow_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ func (m mockStowContainer) Items(prefix, cursor string, count int) ([]stow.Item,
numItems := endIndexExc - startIndex
results := make([]stow.Item, numItems)
for index, itemKey := range itemKeys[startIndex:endIndexExc] {
url := fmt.Sprintf("s3://%s/%s", m.id, m.items[itemKey].url)
results[index] = mockStowItem{url: url, size: m.items[itemKey].size}
url := fmt.Sprintf("s3://%s/%s", m.id, m.items[itemKey].name)
results[index] = mockStowItem{url: url, size: m.items[itemKey].size, name: m.items[itemKey].name}
}

if endIndexExc == len(m.items) {
Expand All @@ -123,7 +123,7 @@ func (m *mockStowContainer) Put(name string, r io.Reader, size int64, metadata m
if m.putCB != nil {
return m.putCB(name, r, size, metadata)
}
item := mockStowItem{url: name, size: size}
item := mockStowItem{url: name, name: name, size: size}
m.items[name] = item
return item, nil
}
Expand All @@ -137,6 +137,7 @@ func newMockStowContainer(id string) *mockStowContainer {

type mockStowItem struct {
url string
name string
size int64
}

Expand All @@ -145,7 +146,7 @@ func (m mockStowItem) ID() string {
}

func (m mockStowItem) Name() string {
return m.url
return m.name
}

func (m mockStowItem) URL() *url.URL {
Expand Down
Loading