Google Cloud FUSE with Cloud Run [Errno 5] Input/output error: '/database' but already granted Storage Object Admin access
Google Cloud FUSE with Cloud Run [Errno 5] Input/output error: '/database' but already granted Storage Object Admin access
我正在将 GCP 的 Cloud FUSE 与 Cloud 运行 一起使用,如 google (https://cloud.google.com/run/docs/tutorials/network-filesystems-fuse#cloudrun_fs_code-python) 在本教程中所述。但是,在我部署该应用程序后,该应用程序无法访问该文件夹,而是在日志 [Errno 5] Input/output error: '/database'
中出现此错误,其中 'database' 是文件夹名称根据我在网上阅读的内容,这通常是由于没有足够的权限。但是,我检查了 Cloud FUSE 的仪表板,我已经授予 Storage Object Admin 访问应用程序服务帐户的权限。
该应用程序是用 python 3.9 编写的。我无法执行 os.listdir('/database')
。但是,当我使用 os.listdir('/')
时,'database' 是列表中的一项,而 os.path.isdir('/database')
returns true.
我不清楚你为什么要找 /database
。
您是在 --update-env-vars=MNT_DIR=/database,BUCKET=...
之前部署的吗?
应用程序默认为 MNT_DIR=/mnt/gcs
,因为这是在 gcsfuse.Dockerfile
中设置的
[Errno 5]
错误从何而来?
我按原样部署了教程中的代码,它对我有用。
它使用 /mnt/gcs
(通过云 运行 端点 url +/mnt/gcs
。
文件是在刷新时创建的,这些文件在 GCS 存储桶中可见。
更新
这是我的端到端脚本:
Q=70354313
BILLING="..." # Your Billing Account
PROJECT="$(whoami)-$(date +%y%m%d)-${Q}" # Or ...
BUCKET="$(whoami)-$(date +%y%m%d)-${Q}" # Or ...
REGION="us-west1" # Or ...
NAME="Whosebug"
MNT_DIR="/database"
ACCOUNT="Whosebug"
EMAIL="${ACCOUNT}@${PROJECT}.iam.gserviceaccount.com"
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
cd python-docs-samples/run/filesystem/
# Use FUSE not Filestore
rm Dockerfile
cp gcsfuse.Dockerfile Dockerfile
# GCP stuff
gcloud projects create ${PROJECT}
gcloud beta billing projects link ${PROJECT} \
--billing-account=${BILLING}
SERVICES=(
"artifactregistry"
"cloudbuild"
"run"
)
for SERVICE in ${SERVICES[@]}
do
gcloud services enable ${SERVICE}.googleapis.com \
--project=${PROJECT}
done
# Create GCS Bucket
gsutil mb -l ${REGION} -p ${PROJECT} gs://${BUCKET}
# Create Service Account
gcloud iam service-accounts create ${ACCOUNT} \
--project=${PROJECT}
gcloud projects add-iam-policy-binding ${PROJECT} \
--member=serviceAccount:${EMAIL} \
--role=roles/storage.objectAdmin
gcloud beta run deploy ${NAME} \
--source=${PWD} \
--execution-environment=gen2 \
--allow-unauthenticated \
--service-account=${ACCOUNT} \
--update-env-vars=MT_DIR=${MNT_DIR},BUCKET=${BUCKET} \
--region=${REGION} \
--project=${PROJECT}
然后:
ENDPOINT=$(\
gcloud run services describe ${NAME} \
--region=${REGION} \
--platform=managed \
--project=${PROJECT} \
--format="value(status.url)") && echo ${ENDPOINT}
# Curl the Cloud Run service endpoint 5 times
for test in {1..5}
do
curl \
--silent \
--location \
--output /dev/null \
--write-out "%{response_code}\n" \
${ENDPOINT}
# Files are only differentiated at minute accuracy
sleep 60s
done
# Enumerate the GCS Bucket
gsutil ls gs://${BUCKET}
在/mnt/gcs
目录下挂载fuse即可解决
我正在将 GCP 的 Cloud FUSE 与 Cloud 运行 一起使用,如 google (https://cloud.google.com/run/docs/tutorials/network-filesystems-fuse#cloudrun_fs_code-python) 在本教程中所述。但是,在我部署该应用程序后,该应用程序无法访问该文件夹,而是在日志 [Errno 5] Input/output error: '/database'
中出现此错误,其中 'database' 是文件夹名称根据我在网上阅读的内容,这通常是由于没有足够的权限。但是,我检查了 Cloud FUSE 的仪表板,我已经授予 Storage Object Admin 访问应用程序服务帐户的权限。
该应用程序是用 python 3.9 编写的。我无法执行 os.listdir('/database')
。但是,当我使用 os.listdir('/')
时,'database' 是列表中的一项,而 os.path.isdir('/database')
returns true.
我不清楚你为什么要找 /database
。
您是在 --update-env-vars=MNT_DIR=/database,BUCKET=...
之前部署的吗?
应用程序默认为 MNT_DIR=/mnt/gcs
,因为这是在 gcsfuse.Dockerfile
[Errno 5]
错误从何而来?
我按原样部署了教程中的代码,它对我有用。
它使用 /mnt/gcs
(通过云 运行 端点 url +/mnt/gcs
。
文件是在刷新时创建的,这些文件在 GCS 存储桶中可见。
更新
这是我的端到端脚本:
Q=70354313
BILLING="..." # Your Billing Account
PROJECT="$(whoami)-$(date +%y%m%d)-${Q}" # Or ...
BUCKET="$(whoami)-$(date +%y%m%d)-${Q}" # Or ...
REGION="us-west1" # Or ...
NAME="Whosebug"
MNT_DIR="/database"
ACCOUNT="Whosebug"
EMAIL="${ACCOUNT}@${PROJECT}.iam.gserviceaccount.com"
git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git
cd python-docs-samples/run/filesystem/
# Use FUSE not Filestore
rm Dockerfile
cp gcsfuse.Dockerfile Dockerfile
# GCP stuff
gcloud projects create ${PROJECT}
gcloud beta billing projects link ${PROJECT} \
--billing-account=${BILLING}
SERVICES=(
"artifactregistry"
"cloudbuild"
"run"
)
for SERVICE in ${SERVICES[@]}
do
gcloud services enable ${SERVICE}.googleapis.com \
--project=${PROJECT}
done
# Create GCS Bucket
gsutil mb -l ${REGION} -p ${PROJECT} gs://${BUCKET}
# Create Service Account
gcloud iam service-accounts create ${ACCOUNT} \
--project=${PROJECT}
gcloud projects add-iam-policy-binding ${PROJECT} \
--member=serviceAccount:${EMAIL} \
--role=roles/storage.objectAdmin
gcloud beta run deploy ${NAME} \
--source=${PWD} \
--execution-environment=gen2 \
--allow-unauthenticated \
--service-account=${ACCOUNT} \
--update-env-vars=MT_DIR=${MNT_DIR},BUCKET=${BUCKET} \
--region=${REGION} \
--project=${PROJECT}
然后:
ENDPOINT=$(\
gcloud run services describe ${NAME} \
--region=${REGION} \
--platform=managed \
--project=${PROJECT} \
--format="value(status.url)") && echo ${ENDPOINT}
# Curl the Cloud Run service endpoint 5 times
for test in {1..5}
do
curl \
--silent \
--location \
--output /dev/null \
--write-out "%{response_code}\n" \
${ENDPOINT}
# Files are only differentiated at minute accuracy
sleep 60s
done
# Enumerate the GCS Bucket
gsutil ls gs://${BUCKET}
在/mnt/gcs
目录下挂载fuse即可解决