【问题标题】:Mounting a GCS bucket on AppEngine Flexible Environment在 AppEngine 柔性环境上挂载 GCS 存储桶
【发布时间】:2017-10-07 13:37:09
【问题描述】:

我正在尝试使用 gcsfuse 在 AppEngine 灵活环境应用上安装 GCS 存储桶。

我的 Dockerfile 包括以下内容:

# gscfuse setup
RUN echo "deb http://packages.cloud.google.com/apt cloud-sdk-jessie main" | tee /etc/apt/sources.list.d/google-cloud.sdk.list
RUN echo "deb http://packages.cloud.google.com/apt gcsfuse-jessie main" | tee /etc/apt/sources.list.d/gcsfuse.list
RUN wget -qO- https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
RUN apt-get update && apt-get install -y --no-install-recommends google-cloud-sdk gcsfuse strace
RUN gcsfuse --implicit-dirs my_bucket my_dir

我从here 获取了大部分内容。这几乎只是安装 gcsfuse 的标准方式,加上--no-install-recommends

如果我以这种方式启动应用程序,它不会安装驱动器。这对我来说并不奇怪,因为它似乎不是柔性环境的支持功能。

这是令人困惑的部分。如果我运行gcloud app instances ssh "<instance>",然后运行container_exec gaeapp /bin/bash,然后gcsfuse my_bucket my_dir 工作正常。

但是,如果我运行 gcloud app instances ssh "<instance>" --container gaeapp,那么 gcsfuse my_bucket my_dir 将失败并出现以下错误:

fusermount: failed to open /dev/fuse: Operation not permitted

这与我在 main.py 中将 gcsfuse 作为子进程运行时遇到的错误相同。

基于此unresolved thread,我运行strace -f 并看到与该用户完全相同的问题,即EPERM 问题。

[pid    59] open("/dev/fuse", O_RDWR)   = -1 EPERM (Operation not permitted)

无论我以何种方式登录到容器(或者如果我从main.py 运行子进程),我都是root 用户。如果我运行export,那么我确实会看到不同的变量,所以运行的内容会有所不同,但其他一切对我来说都是一样的。

我看到的其他建议包括使用 gcsfuse 标志 -o allow_other-o allow_root。这些都不起作用。

可能有一个线索,如果我尝试在无法运行gcsfuse 的登录上运行umount,它会显示"must be superuser to unmount",即使我是root。

似乎有一些我不明白的安全设置。但是,由于理论上我可以让main.py 触发外部程序登录并为我运行gcsfuse,因此似乎应该有一种方法可以让它工作而不必这样做。

【问题讨论】:

    标签: google-app-engine fuse google-app-engine-python app-engine-flexible gcsfuse


    【解决方案1】:

    RUN 命令是为您的 dockerfile 创建一个新层,因此您实际上是在创建映像期间运行该命令,这是 Flex 构建系统不喜欢的。

    我不确定为什么在应用程序中进行脱壳不起作用,您可以尝试在 python 子进程中对其进行“sudo”处理,或者通过将“gcsfuse setup &&”添加到应用程序代码中来将其推出应用程序代码dockerfile 中的 ENTRYPOINT。

    【讨论】:

    • 谢谢乔恩。我尝试了这些想法。入口点对我不起作用(运行 gcsfuse 命令 && gunicorn)。尝试从 python 子进程调用 sudo 不起作用,因为找不到 sudo (无论如何用户都是 root)。对我来说主要的谜团是 sshing 到实例,然后运行 ​​container_exec(gcsfuse 有效)与 sshing 与 --container gaeapp(gcsfuse 失败)之间的区别。
    猜你喜欢
    • 1970-01-01
    • 2023-03-24
    • 2020-09-17
    • 2017-10-19
    • 1970-01-01
    • 2021-02-21
    • 2017-08-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多