seaweedfs: New version of seaweedfs can't list directory using s3 api

Sponsors SeaweedFS via Patreon https://www.patreon.com/seaweedfs Report issues here. Ask questions here https://stackoverflow.com/questions/tagged/seaweedfs Please ask questions in https://github.com/seaweedfs/seaweedfs/discussions

Describe the bug Let me show you the behaviour, the client I used was minio client. with seaweed version 3.53 and 3.43

# using weed version 3.53
$ mc ls weed-admin/images/reverse_bag_images/
# NO OUTPUT FOR THE ABOVE COMMAND
$ mc ls weed-admin/images/reverse_bag_images
[2023-07-12 12:06:09 +07]     0B reverse_bag_images/

# revert update to version 3.43
$ mc ls weed-admin/images/reverse_bag_images
[2023-07-12 12:13:17 +07]     0B 2023-07-03/
[2023-07-12 12:13:17 +07]     0B 2023-07-04/
$ mc ls weed-admin/images/reverse_bag_images/
[2023-07-12 12:13:19 +07]     0B 2023-07-03/
[2023-07-12 12:13:19 +07]     0B 2023-07-04/

As you can see from the above output, s3 file list was only working when I uses the older version of seaweedfs.

My story

I was happily using seaweedfs for a long time without any problem, until yesterday that I try update my servers to newest version, that I encounter this problem. After browsing through the releases changes log, I suspect this release. My current solution is to revert the update, and continue to use 3.43 for now.

System Setup

$ uname -a
Linux example-storage-2 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

$ weed version
version 30GB 3.43 3227e4175e2bf8df2ac8aeeff8cf73a819abc5a7 linux amd64

$ /usr/bin/weed master -mdir=/etc/seaweedfs/weed-meta -ip=storage2.example.com -ip.bind=0.0.0.0 -port=9333 -defaultReplication=010 -peers=storage3.example.com:9333,storage4.example.com:9333
$ /usr/bin/weed volume -mserver=storage2.example.com:9333,storage3.example.com:9333,storage4.example.com:9333 -max=0 -ip.bind=0.0.0.0 -port=8081 -dataCenter=main-site -rack=example-storage-2 -dir=/mnt/nvme1/seaweedfs,/mnt/nvme2/seaweedfs,/mnt/nvme3/seaweedfs,/mnt/nvme4/seaweedfs
$ /usr/bin/weed filer -master=storage2.example.com:9333,storage3.example.com:9333,storage4.example.com:9333 -dataCenter=main-site -ip=storage2.example.com -ip.bind=0.0.0.0 -s3 -s3.dataCenter=main-site -s3.config=/etc/seaweedfs/s3-config.json -s3.cert.file=/data/letsencrypt/certificates/example-storage-2.example.com.crt -s3.key.file=/data/letsencrypt/certificates/example-storage-2.example.com.key
$ cat /etc/seaweedfs/filer.toml
# A TOML config file for SeaweedFS filer store

####################################################
# Customizable filer server options
####################################################
[filer.options]
# with http DELETE, by default the filer would check whether a folder is empty.
# recursive_delete will delete all sub folders and files, similar to "rm -Rf"
recursive_delete = false

####################################################
# The following are filer store options
####################################################
# We're forced to use redis sentinel since redis cluster require at least 6 nodes (we have only 4)
[redis3_sentinel]
enabled = true
addresses = ["redis1.storage.example:26379","redis2.storage.example:26379","redis3.storage.example:26379","redis4.storage.example:26379"]
masterName = "mymaster"
username = "default"
password = "RETRACTED"
database = 0

Expected behavior I expect that I can use s3 api to list files

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 42 (18 by maintainers)

Commits related to this issue

Most upvoted comments

@chrislusf @kmlebedev After code review and debug,I found the root cause:

ListDirectoryPrefixedEntries in weed/filer/filerstore_wrapper.go called.

and it will try to use ListDirectoryPrefixedEntries of actualStore to get the file list

and when ListDirectoryPrefixedEntries return ErrUnsupportedListDirectoryPrefixed ERROR

it will fall back to ListDirectoryEntries with https://github.com/seaweedfs/seaweedfs/blob/117fbba5bf1947a280376e688d24b3a9b1c589c9/weed/filer/filerstore_wrapper.go#L277-L320

it will works well in the past , but unfortunately,with https://github.com/seaweedfs/seaweedfs/pull/4391 the parameter “limit” set to 1 so it will only worked well when the directory you list is the first of the parent directory.

restic init create only one directory named keys and it worked well, after we restic backup directory “data” and other directory created by restic. so s3api cannot list keys directory , it report the key error

I am not familiar with golang , but if I thought change the limit parameter in the fall back in https://github.com/seaweedfs/seaweedfs/blob/117fbba5bf1947a280376e688d24b3a9b1c589c9/weed/filer/filerstore_wrapper.go#L271-L273 will fix this bug and not need to full fill every ListDirectoryPrefixedEntries in every kind of filer store.

I found the same problem . s3api cannot list object with prefix when filer store is Cassandra is there any progress on this issue?

Hey, I was testing SeaweedFS with our cross-platform S3 GUI (https://s3drive.app/) and can confirm that problem is present in 3.55 and is not present in 3.45.

This creates: explicitFolder/ key: Screenshot from 2023-08-08 13-35-44

3.55 (INCORRECT)

Screenshot from 2023-08-08 13-38-05

3.45 (CORRECT)

Screenshot from 2023-08-08 13-38-14

The implicitFolder (folder without explicit key/entry ending with /, but instead virtual CommonPrefix derived from all of the files and sub-folders inside of that folder) works fine on both versions: Screenshot from 2023-08-08 13-37-17

Alternative way - using AWS CLI

Insert key

aws --endpoint=http://localhost:8333/ s3api put-object --bucket seabucket --key explicit/

Query

aws --endpoint=http://localhost:8333/ s3api list-objects-v2 --bucket seabucket --prefix explicit --delimiter "/"

Response 3.55 (INCORRECT)

{
    "Contents": [
        {
            "Key": "explicit/",
            "LastModified": "2023-08-08T11:22:57+00:00",
            "ETag": "\"d41d8cd98f00b204e9800998ecf8427e-0\"",
            "Size": 0,
            "StorageClass": "STANDARD",
            "Owner": {
                "ID": "3e8"
            }
        }
    ]
}

Response 3.45 (CORRECT)

{
    "CommonPrefixes": [
        {
            "Prefix": "explicit/"
        }
    ]
}

S3 Filer CMD

I wasn’t touching master or volume processes, I was only switching version of S3 Filer.

# v3.55
weed filer -s3 -ip=127.0.0.1 -master=127.0.0.1:9333
# v3.45
weed345 filer -s3 -ip=127.0.0.1 -master=127.0.0.1:9333

CORS missing

You would be able to try it out using our S3 browser client (https://web.s3drive.app) but it I wasn’t able to setup CORS properly for SeaweedFS without running front NginX.

Hello,

@chrislusf have you been able to reproduce it yet?

I can confirm this happened with the release of 3.46. Directory listings using the s3 service works as expected through version 3.45.

It is not clear to me which of these two PRs might have caused the issue #4390 or #4391