简体   繁体   English

在Hosted Linux Agent上运行VSTS构建期间挂载Azure文件存储失败

[英]Mounting Azure file storage during VSTS build running on Hosted Linux Agent fails

I've got a storage account (classic) setup with a file share. 我有一个带有文件共享的存储帐户(经典)设置。 I used the information from "Connecting from Linux" ( https://docs.microsoft.com/en-us/azure/storage/storage-file-how-to-use-files-portal#connect-to-file-share ) to mount the share as a build step using the following shell script: 我使用了“从Linux连接”( https://docs.microsoft.com/zh-cn/azure/storage/storage-file-how-to-use-files-portal#connect-to-file-share )使用以下shell脚本将共享作为构建步骤安装:

sudo apt-get -y update
echo Installing cifs-utils

sudo apt-get -y install cifs-utils

SHARE=$PWD/buildartifacts
echo Creating $SHARE
if [ ! -d $SHARE ]; then
  sudo mkdir $SHARE
fi

echo Mounting $SHARE
sudo mount -t cifs $1 $SHARE -o vers=3.0,username=$2,password=$3,dir_mode=0777,file_mode=0777

I pass in the share path, username and password from the VSTS build. 我从VSTS构建中传递共享路径,用户名和密码。

This is the tail of the output I get from the build: 这是我从构建中得到的输出的尾部:

2017-07-12T11:56:01.0208730Z Creating config file /etc/samba/smb.conf with new version
2017-07-12T11:56:01.2016540Z Setting up libcap-ng0:amd64 (0.7.7-1) ...
2017-07-12T11:56:01.2433760Z Setting up libtalloc2:amd64 (2.1.5-2) ...
2017-07-12T11:56:01.2823630Z Setting up cifs-utils (2:6.4-1ubuntu1.1) ...
2017-07-12T11:56:01.3532550Z Setting up keyutils (1.5.9-8ubuntu1) ...
2017-07-12T11:56:01.4042470Z Setting up libtdb1:amd64 (1.3.8-2) ...
2017-07-12T11:56:01.4382800Z Setting up libtevent0:amd64 (0.9.28-0ubuntu0.16.04.1) ...
2017-07-12T11:56:01.4748150Z Setting up libldb1:amd64 (2:1.1.24-1ubuntu3) ...
2017-07-12T11:56:01.5114810Z Setting up python-crypto (2.6.1-6ubuntu0.16.04.2) ...
2017-07-12T11:56:01.9924790Z Setting up python-ldb (2:1.1.24-1ubuntu3) ...
2017-07-12T11:56:02.0912580Z Setting up python-tdb (1.3.8-2) ...
2017-07-12T11:56:02.1932370Z Setting up python-talloc (2.1.5-2) ...
2017-07-12T11:56:02.2329750Z Setting up samba-libs:amd64 (2:4.3.11+dfsg-0ubuntu0.16.04.8) ...
2017-07-12T11:56:02.2687050Z Setting up python-samba (2:4.3.11+dfsg-0ubuntu0.16.04.8) ...
2017-07-12T11:56:02.6471400Z Setting up samba-common-bin (2:4.3.11+dfsg-0ubuntu0.16.04.8) ...
2017-07-12T11:56:02.6860280Z Processing triggers for libc-bin (2.23-0ubuntu7) ...
2017-07-12T11:56:02.8437710Z Creating /opt/vsts/work/1/s/buildartifacts
2017-07-12T11:56:02.8522080Z Mounting /opt/vsts/work/1/s/buildartifacts
2017-07-12T11:56:02.8613570Z Unable to apply new capability set.
2017-07-12T11:56:02.8828840Z ##[error]/bin/bash failed with return code: 2
2017-07-12T11:56:02.8873290Z ##[error]Bash failed with error: /bin/bash failed with return code: 2
2017-07-12T11:56:02.9474600Z ##[section]Finishing: Shell Script setup-hosted.sh

I have managed to get this working on the Windows Hosted Agent where I used: 我已经设法在我使用过的Windows Hosted Agent上执行此操作:

net use <share> /u:AZURE\<username> <password>

The difference here is that I then access the files directory without a drive letter: 区别在于,我然后访问文件目录而没有驱动器号:

/path/to/file It seems that the Hosted Linux Agent for VSTS is not configured to allow mounting cifs shares. / path / to / file似乎未将VSTS托管Linux代理配置为允许挂载cifs共享。 Is this correct and the expected behavior? 这是正确的预期行为吗?

Additional information: 附加信息:

The VM capability set returned by: VM功能集返回:

sudo capsh --print

outputs: 输出:

Current: = cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap+eip
Bounding set =cap_chown,cap_dac_override,cap_fowner,cap_fsetid,cap_kill,cap_setgid,cap_setuid,cap_setpcap,cap_net_bind_service,cap_net_raw,cap_sys_chroot,cap_mknod,cap_audit_write,cap_setfcap
Securebits: 00/0x0/1'b0
 secure-noroot: no (unlocked)
 secure-no-suid-fixup: no (unlocked)
 secure-keep-caps: no (unlocked)
uid=0(root)
gid=0(root)
groups=0(root)

According to the capabilities(7) man page: 根据功能(7)手册页:

CAP_SYS_ADMIN
          * Perform a range of system administration operations including: quotactl(2), mount(2), umount(2), swapon(2), swapoff(2), sethostname(2), and setdomainname(2);

and from mount(2): 并从mount(2):

Appropriate privilege (Linux: the CAP_SYS_ADMIN capability) is required to mount filesystems.

The agent for the "Hosted Linux Preview" pool is actually running inside of a container, and it looks like special capabilities are required for mounting that filesystem while running inside a container. “托管Linux预览”池的代理实际上是在容器内部运行的,看起来在容器内运行时挂载该文件系统需要特殊功能。

Deeper integration with Docker and containers is planned for VSTS very soon, which should lead to a change in how the "Hosted Linux Preview" pools work in general. VSTS计划很快与Docker和容器进行更深入的集成,这将导致“托管Linux预览”池的总体工作方式发生变化。

Until then, a (slightly hacky) work-around could involve spinning up a second container with the correct capabilities (the host's docker daemon is mounted inside of the container the agent is running in) to mount the drive in a shared folder with the current agent container. 在此之前,(略为hacky)的变通方法可能包括旋转具有正确功能的第二个容器(主机的docker守护程序安装在代理正在运行的容器内部),以将驱动器安装在具有当前功能的共享文件夹中。代理容器。

The Linux SMB3 client doesn't support share level encryption yet, so mounting a file share in Linux only works from virtual machines running in the same Azure region as the file share. Linux SMB3客户端尚不支持共享级别加密,因此在Linux中挂载文件共享仅适用于与文件共享在同一Azure区域中运行的虚拟机。

Go to settings page of your VSTS and check Region ( https://[account].visualstudio.com/_admin/_home/settings ), then compare with your storage region. 转到VSTS的“设置”页面,然后检查“区域”( https://[account].visualstudio.com/_admin/_home/settings ),然后与您的存储区域进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 是否可以在VSTS 2017托管代理上构建Linux docker镜像? - Is it possible to build a Linux docker image on VSTS 2017 Hosted agent? 找不到VSTS构建问题文件&#39;git&#39;-Linux Private Agent - VSTS build issue file not found 'git' - Linux private agent 如何通过 bash 检查 Linux 上自托管 Azure DevOps 代理上正在运行的作业 - How to check running job on self-hosted Azure DevOps Agent on Linux via bash 为 Azure devops 服务器安装自托管 Linux 代理 - Installing Self Hosted Linux Agent for Azure devops Server 如何找到正确的托管代理来构建Linux代码? - How to find correct hosted agent to build Linux code? Azure DevOps:“托管Linux预览”和“托管Ubuntu 1604”代理池之间有什么区别? - Azure DevOps: What's the difference between the “Hosted Linux Preview” and “Hosted Ubuntu 1604” agent pools? 如何从vsts中的Linux托管代理输出npm build错误日志文件? - How to output npm build error log files from linux hosted agents in vsts? 在Linux托管代理上找不到Dockerfile - Dockerfile not found on Linux hosted agent Azure 构建代理 - Azure build Agent 从官方Wordpress映像挂载单个文件时,Docker(compose)无法构建容器 - Docker (compose) fails to build container when mounting single file from official Wordpress image
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM