添加 --implicit-dirs 选项后无法读取已挂载的 GCSFuse 目录

问题描述 投票:0回答:1

我已经使用 gcsfuse 安装了 GCS 存储桶,更新启动脚本以包含 --implicit-dirs 后,我无法再从安装的目录 /gcs/my-bucket 中读取数据。尝试列出文件 (ls) 或访问目录时收到“输入/输出错误”。但是,虽然我无法直接访问 /gcs/my-bucket 目录,但我可以访问其子目录中的文件。权限似乎正确,并且我拥有存储的完全访问权限设置。

我添加了 --implicit-dirs 标志来解决与访问使用 GCP SDK 上传的文件相关的问题。有时 vm 无法访问这些文件,但可以访问通过 gcsfuse 上传的文件。

云 API 访问范围(VM 权限)

Allow custom access
BigQuery Disabled
Bigtable Admin Disabled
Bigtable Data Disabled
Cloud Datastore Disabled
Cloud Debugger Disabled
Cloud Platform Disabled
Cloud Pub/Sub Disabled
Cloud Source Repositories Full
Cloud SQL Disabled
Compute Engine Disabled
Service Control Enabled
Service Management Read Only
Stackdriver Logging API Write Only
Stackdriver Monitoring API Write Only
Stackdriver Trace Write Only
Storage Full
Task queue Disabled
User info Disabled

服务帐户权限: Firebase 测试实验室查看器 日志编写器 存储管理员 存储对象管理 存储对象创建者

vm的启动脚本:

#! /bin/bash
gcsfuse --implicit-dirs --foreground --debug_gcs -o rw,allow_other my-bucket /gcs/my-bucket
chmod 777 /gcs/my-bucket

gcsfuse 日志:

"startup-script: {"timestamp":{"seconds":1718604762,"nanos":135066298},"severity":"INFO","message":"Start gcsfuse/2.1.0 (Go version go1.22.3) for app \"\" using mount point: /gcs/my-bucket\n"}"
startup-script: {"timestamp":{"seconds":1718604762,"nanos":135769488},"severity":"INFO","message":"GCSFuse mount command flags: {\"AppName\":\"\",\"Foreground\":true,\"ConfigFile\":\"\",\"MountOptions\":{\"allow_other\":\"\",\"ro\":\"\"},\"DirMode\":493,\"FileMode\":420,\"Uid\":-1,\"Gid\":-1,\"ImplicitDirs\":true,\"OnlyDir\":\"\",\"RenameDirLimit\":0,\"IgnoreInterrupts\":false,\"CustomEndpoint\":null,\"BillingProject\":\"\",\"KeyFile\":\"\",\"TokenUrl\":\"\",\"ReuseTokenFromUrl\":true,\"EgressBandwidthLimitBytesPerSecond\":-1,\"OpRateLimitHz\":-1,\"SequentialReadSizeMb\":200,\"AnonymousAccess\":false,\"MaxRetrySleep\":30000000000,\"StatCacheCapacity\":20460,\"StatCacheTTL\":60000000000,\"TypeCacheTTL\":60000000000,\"HttpClientTimeout\":0,\"MaxRetryDuration\":-1000000000,\"RetryMultiplier\":2,\"LocalFileCache\":false,\"TempDir\":\"\",\"ClientProtocol\":\"http1\",\"MaxConnsPerHost\":0,\"MaxIdleConnsPerHost\":100,\"EnableNonexistentTypeCache\":false,\"StackdriverExportInterval\":0,\"OtelCollectorAddress\":\"\",\"LogFile\":\"\",\"LogFormat\":\"json\",\"ExperimentalEnableJsonRead\":false,\"DebugFuseErrors\":true,\"DebugFuse\":false,\"DebugFS\":false,\"DebugGCS\":true,\"DebugHTTP\":false,\"DebugInvariants\":false,\"DebugMutex\":false}"}
startup-script: {"timestamp":{"seconds":1718604762,"nanos":135881882},"severity":"INFO","message":"GCSFuse mount config flags: {\"CreateEmptyFile\":false,\"Severity\":\"TRACE\",\"Format\":\"json\",\"FilePath\":\"\",\"LogRotateConfig\":{\"MaxFileSizeMB\":512,\"BackupFileCount\":10,\"Compress\":true},\"MaxSizeMB\":-1,\"CacheFileForRangeRead\":false,\"CacheDir\":\"\",\"TtlInSeconds\":-9223372036854775808,\"TypeCacheMaxSizeMB\":4,\"StatCacheMaxSizeMB\":-9223372036854775808,\"EnableEmptyManagedFolders\":false,\"ConnPoolSize\":1,\"AnonymousAccess\":false,\"EnableHNS\":false,\"IgnoreInterrupts\":false}"}
$ mount
my-bucket on /gcs/my-bucket type fuse.gcsfuse (rw,nosuid,nodev,relatime,user_id=0,group_id=0,default_permissions,allow_other)
$ df -h
Filesystem      Size  Used Avail Use% Mounted on
my-bucket      1.0P     0  1.0P   0% /gcs/my-bucket
/gcs$ ls -al my-bucket/
ls: reading directory 'my-bucket/': Input/output error
total 0
/gcs$ $ ls -al my-bucket/prod
total 0
drwxr-xr-x 1 root root 0 Jun 17 07:25 folder1
drwxr-xr-x 1 root root 0 Jun 17 07:25 folder2


Steps Already Tried:
- Checking permissions on the Google Cloud Console.
- Remounting the bucket without the --implicit-dirs option (which resolves the reading issue but doesn't work for my use case).
- Verifying the service account has adequate permissions.


I'm looking for any advice on what might be causing this and how to resolve it so that I can use --implicit-dirs without losing read access. Thanks in advance for your help!
google-cloud-platform cloud virtual-machine mount gcsfuse
1个回答
0
投票

GCSFuse 不支持路径中名称为空的目录(带有双斜杠的对象)。例如:

gsutil cp <file-name>  gs://<bucket-name>//<file-name>

将在存储桶上创建一个空目录,并可能在挂载到 gcsfuse 中时导致此类输入/输出错误。

从存储桶中删除此空目录应该可以解决问题。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.