Poudriere: 12-stable,在监狱里运行

创建于 2018-12-10  ·  17评论  ·  资料来源: freebsd/poudriere

自从几天前升级到 12-stable 以来,我在监狱内运行 poudriere 时遇到了麻烦。 对我的配置没有任何更改,我现在得到jail: IPv4 addresses clash而在构建期间启动 poudriere builder jail:

# poudriere bulk -j 12amd64 -p local -z zs64 -f /root/11amd64-local-zs64-pkglist
[00:00:00] Creating the reference jail... done
[00:00:01] Mounting system devices for 12amd64-local-zs64
[00:00:01] Mounting ports/packages/distfiles
[00:00:01] Using packages from previously failed build
[00:00:01] Mounting ccache from: /var/cache/ccache
[00:00:01] Mounting packages from: /p/data/packages/12amd64-local-zs64
[00:00:02] Appending to make.conf: /usr/local/etc/poudriere.d/make.conf
[00:00:02] Appending to make.conf: /usr/local/etc/poudriere.d/zs64-make.conf
/etc/resolv.conf -> /p/data/.m/12amd64-local-zs64/ref/etc/resolv.conf
[00:00:02] Starting jail 12amd64-local-zs64
jail: IPv4 addresses clash
[00:00:02] Cleaning up
[00:00:02] Unmounting file systems

我已经摆弄了 LOIP4 和 LOIP6 以及外部监狱 IP 配置,但无济于事。

检查common.sh的代码,似乎 poudriere 试图确定将哪些 IP 传递给监狱启动调用,即ip4.addrip6.addr 。 我已将localipargs硬重置case $IPS块之后),这使我的构建再次正常工作。

这是与 12-stable 的潜在不兼容吗?

Base Issue

最有用的评论

通过使用 VIMAGE 和 vnet jail,我设法再次获得了工作设置。 如果“经典”共享 IP 设置可以工作,我想听听如何。

所有17条评论

该死,即使有那个补丁,Python 和 Ruby 也无法构建。

Python:

checking getaddrinfo bug... yes
Fatal: You must get working getaddrinfo() function.
       or you can specify "--disable-ipv6".
===>  Script "configure" failed unexpectedly.

红宝石:

compiling raddrinfo.c
raddrinfo.c:214:17: warning: implicit declaration of function 'parse_numeric_port' is invalid in C99 [-Wimplicit-function-declaration]
    if (node && parse_numeric_port(service, &port)) {
                ^
1 warning generated.
compiling ifaddr.c
compiling getaddrinfo.c
In file included from getaddrinfo.c:86:
./addrinfo.h:165:12: error: conflicting types for 'getnameinfo'
extern int getnameinfo __P((
           ^
/usr/include/netdb.h:251:6: note: previous declaration is here
int             getnameinfo(const struct sockaddr *, socklen_t, char *,
                ^
getaddrinfo.c:408:7: warning: add explicit braces to avoid dangling else [-Wdangling-else]
                                } else if (strcmp(sp->s_proto, "tcp") == 0) {
                                  ^
1 warning and 1 error generated.
*** Error code 1

通过使用 VIMAGE 和 vnet jail,我设法再次获得了工作设置。 如果“经典”共享 IP 设置可以工作,我想听听如何。

在 12.0-RELEASE-p2 jail 中构建 ruby​​ 仍然失败。
在 11.2-RELEASE-p8 jail 中构建 ruby​​。
任何见解?

附上构建日志:
ruby-2.5.3_1,1.log

@stblassitude你需要修改什么才能让它工作? 具体在哪里需要vnet选项? 在监狱里 Poudriere 是在还是 Poudriere 创建的监狱里?

我认为一种解决方法可能是设置一个唯一的环回地址:

LOIP4=127.0.0.2
LOIP6=::2

@bdrewery ,使用您建议的设置会生成相同的警告和错误:
(也试过 LOIP4="127.0.0.2/32")。 似乎 LOIP4 被忽略了。 应该在其他地方设置吗?
在外部设置 poudriere jail 的环回也失败。

grep '^[AZ]' /usr/local/etc/poudriere.conf

LOIP4=127.0.0.2
LOIP6=::2
NO_ZFS=是
FREEBSD_HOST= ftp://ftp.freebsd.org
RESOLV_CONF=/etc/resolv.conf
BASEFS=/p
USE_PORTLINT=否
USE_TMPFS=否
DISTFILES_CACHE=/usr/ports/distfiles
NOLINUX=是
ALLOW_MAKE_JOBS=是

[00:00:00] Warning: No loopback address defined, consider setting LOIP6/LOIP4 or assigning a loopback address to the jail.
[00:00:00] Updating portstree "default" with portsnap...Looking up portsnap.FreeBSD.org mirrors... 6 mirrors found.
In file included from getaddrinfo.c:86:
./addrinfo.h:165:12: error: conflicting types for 'getnameinfo'
extern int getnameinfo __P((
           ^
/usr/include/netdb.h:251:6: note: previous declaration is here
int             getnameinfo(const struct sockaddr *, socklen_t, char *,
                ^
--- ext/cgi/escape/all ---
--- escape.o ---
compiling escape.c
--- ext/ripper/all ---
--- pre-install-rb-default ---
installing default ripper libraries
--- ../../.ext/common/ripper.rb ---
--- ext/json/all ---
--- ../../.ext/common/json/add/rational.rb ---
--- ext/fiddle/all ---
--- fiddle.o ---
--- ext/openssl/all ---
--- ossl.o ---
--- ext/fiddle/all ---
compiling fiddle.c
--- ext/openssl/all ---
compiling ossl.c
--- ext/rbconfig/sizeof/all ---
--- limits.o ---
compiling limits.c
--- ext/socket/all ---
getaddrinfo.c:408:7: warning: add explicit braces to avoid dangling else [-Wdangling-else]
                                } else if (strcmp(sp->s_proto, "tcp") == 0) {
                                  ^
--- ext/bigdecimal/all ---
--- ../../.ext/common/bigdecimal/math.rb ---
--- ext/socket/all ---
1 warning and 1 error generated.
*** [getaddrinfo.o] Error code 1

@bdrewery ,使用您建议的设置会生成相同的警告和错误:
(也试过 LOIP4="127.0.0.2/32")。 似乎 LOIP4 被忽略了。 应该在其他地方设置吗?

这是因为common.sh中的这段代码:

# If in a nested jail we may not even have a loopback to use.            
if [ ${JAILED} -eq 1 ]; then                                             
        # !! Note these exit statuses are inverted                       
        ifconfig | \                                                     
            awk -vip="${LOIP6}" '$1 == "inet6" && $2 == ip {exit 1}' && \
            LOIP6=                                                       
        ifconfig | \                                                     
            awk -vip="${LOIP4}" '$1 == "inet" && $2 == ip {exit 1}' && \ 
            LOIP4=                                                       
fi                                                                       

暂时尝试删除它。 它试图确保当前监狱具有您尝试分配给嵌套监狱的 IP。 (有问题的回归。)

将其注释掉时,将显示以下内容,并且不会进行任何构建:

jail: jail_set: Operation not permitted

为了确认一下,我正在运行 FreeBSD 12.0-RELEASE-p3 GENERIC 的主机上的 iocage jail 中运行 Poudriere

# iocage list -l
+------+------------+------+-------+------+-----------------+--------------------+-----+----------+----------+
| JID  |    NAME    | BOOT | STATE | TYPE |     RELEASE     |        IP4         | IP6 | TEMPLATE | BASEJAIL |
+======+============+======+=======+======+=================+====================+=====+==========+==========+
| 2963 | poudriere  | on   | up    | jail | 12.0-RELEASE-p3 | lo1|192.168.250.10 | -   | -        | no       |

对于下面列出的监狱,ruby 的编译失败:

root<strong i="12">@poudriere</strong>:~ # poudriere jail -l
[00:00:00] Warning: No loopback address defined, consider setting LOIP6/LOIP4 or assigning a loopback address to the jail.
JAILNAME    VERSION         ARCH  METHOD TIMESTAMP           PATH
11_2        11.2-RELEASE-p9 amd64 ftp    2019-03-05 13:49:56 /p/jails/11_2
12_0        12.0-RELEASE-p3 amd64 ftp    2019-03-05 13:52:05 /p/jails/12_0

@stblassitude你需要修改什么才能让它工作? 具体在哪里需要vnet选项? 在监狱里 Poudriere 是在还是 Poudriere 创建的监狱里?

这是我的jail.conf

mount.devfs;
devfs_ruleset = 4;

exec.clean;
exec.jail_user = "root";
exec.system_user = "root";
exec.consolelog = "/var/log/jail_${name}.log";
exec.prestart = "/root/bin/jail-helper prestart ${name} ${host.hostname} ${path}";
exec.poststop = "/root/bin/jail-helper poststop ${name} ${host.hostname} ${path}";
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
interface = "bridge0";
allow.raw_sockets;
allow.sysvipc;
...
pkg {
        path = "/jail/pkg.zs64.net";
        vnet;
        vnet.interface = "ji${name}";
        host.hostname = "pkg.zs64.net";
        children.max = 40;
        exec.prestart += "/root/bin/jail-helper prevnet ${name} bridge1";
        exec.poststart += "zfs jail $name data/jail/${host.hostname}/poudriere";
        exec.poststart += "jexec $name zfs mount -a";
        #exec.prestop += "zfs unjail $name data/jail/${host.hostname}/poudriere";
        exec.poststop += "/root/bin/jail-helper postvnet ${name}";
        allow.mount;
        allow.mount.devfs;
        allow.mount.linprocfs;
        allow.mount.nullfs;
        allow.mount.procfs;
        allow.mount.tmpfs;
        allow.mount.zfs;
        allow.socket_af;
        allow.chflags;
        enforce_statfs=1;
}

帮助脚本执行以下操作:

#!/bin/sh

#
# Mount system directories via nullfs
#

cmd="$1"
name="$2"
host="$3"
path="$4"

rofs="/bin /lib /libexec /sbin /usr/bin /usr/include /usr/lib /usr/libdata /usr/libexec /usr/sbin /usr/share /usr/ports"

mountall() {
    mount -t devfs -o ruleset=10 devfs ${path}/dev
    ls ${path}/dev/null >/dev/null
    for i in $rofs; do
        mount -t nullfs -o ro "${i}" "${path}${i}"
    done
    mount -t nullfs -w /freebsd/distfiles ${path}/var/ports/distfiles
}

umountall() {
    mount | \
        sed -nEe 's#.* on ('"${path}"'/[^ ]*) \(.*#\1#p' | \
        sort -r | \
        xargs -n1 umount
}

vnet_create() {
    ifname="$(/sbin/ifconfig epair create)"
    ifbase="${ifname%%a}"
    /sbin/ifconfig "${ifbase}a" up name "jo${name}" >/dev/null
    /sbin/ifconfig "${ifbase}b" name "ji${name}" >/dev/null
    /sbin/ifconfig "${host}" addm "jo${name}"
}

vnet_destroy() {
    /sbin/ifconfig "jo${name}" destroy 2>/dev/null || true
}

case ${cmd} in
    prestart)
        umountall
        mountall
        ;;
    prevnet)
        vnet_destroy
        vnet_create
        ;;
    poststop)
        umountall
        ;;
    postvnet)
        vnet_destroy
        ;;
esac

pkg监狱中,我使用这个poudriere.conf

BASEFS=/usr/local/poudriere
CCACHE_DIR=/var/cache/ccache
DISTFILES_CACHE=/var/ports/distfiles
FREEBSD_HOST=https://download.FreeBSD.org
PKG_REPO_SIGNING_KEY=/usr/local/etc/poudriere.key
TMPFS_LIMIT=6
URL_BASE=http://pkg.example.com
ZPOOL=data
ZROOTFS=/jail/pkg.example.com/poudriere

ZFS 数据集在监狱中看起来像这样:

$ zfs list
NAME                                             USED  AVAIL  REFER  MOUNTPOINT
data                                            1.74T   858G    88K  /data
data/jail                                       1.33T   858G    96K  /jail
data/jail/pkg.example.com                          34.2G   858G  5.54G  /jail/pkg.example.com
data/jail/pkg.example.com/poudriere                24.3G   858G    88K  /p
data/jail/pkg.example.com/poudriere/data           19.1G   858G    96K  /p/data
data/jail/pkg.example.com/poudriere/data/.m        11.6G   858G   112K  /p/data/.m
data/jail/pkg.example.com/poudriere/data/cache      260M   858G  23.8M  /p/data/cache
data/jail/pkg.example.com/poudriere/data/logs      3.17G   858G  2.74G  /p/data/logs
data/jail/pkg.example.com/poudriere/data/packages  4.12G   858G  1.95G  /p/data/packages
data/jail/pkg.example.com/poudriere/data/wrkdirs     88K   858G    88K  /p/data/wrkdirs
data/jail/pkg.example.com/poudriere/jails          1.27G   858G    88K  /p/jails
data/jail/pkg.example.com/poudriere/jails/11amd64    88K   858G    88K  /usr/local/poudriere/jails/11amd64
data/jail/pkg.example.com/poudriere/jails/12amd64  1.27G   858G  1.24G  /usr/local/poudriere/jails/12amd64
data/jail/pkg.example.com/poudriere/ports          3.91G   858G    88K  /p/ports
data/jail/pkg.example.com/poudriere/ports/local    3.91G   858G   903M  /usr/local/poudriere/ports/local

我相信我也有这个问题,但是因为我是在 12 上第一次尝试的,所以我不认为它与 12 升级有关。 只是看看你们在这里想出了什么解决方案。

我找到了测试用例,使用 IPv6 选项和双栈监狱构建lang/python27lang/python3

如果poudriere jail导出jail.conf
ip4=inherit; ip6=inherit;
建立成功

如果导出ip4.addrip6.addr地址构建在配置上失败
checking for getaddrinfo... yes checking getaddrinfo bug... yes Fatal: You must get working getaddrinfo() function. or you can specify "--disable-ipv6".
禁用选项 IPv6 修复构建。

显然现在是 IPv6 设置 lo 中的某个错误 (::1/128) 而不是 /8

有趣的是,区别并不在于交互式工作者是什么。
如果使用bulk -i自动构建失败配置,则在此监狱中手动构建成功
make -C /usr/ports/lang/python27/ .... checking for getaddrinfo... yes checking getaddrinfo bug... no checking for getnameinfo... (cached) yes .... creating Makefile ....

RESTRICT_NETWORKING=no解决了这个问题,也许添加NO_RESTRICT_NETWORKING_PACKAGES="python27 ..."类似的ALLOW_NETWORKING_PACKAGES

通过使用 VIMAGE 和 vnet jail,我设法再次获得了工作设置。 如果“经典”共享 IP 设置可以工作,我想听听如何。

基于上述评论,我还采用了vnet解决方案。 为我工作。 谢谢你。

@stblassitude你需要修改什么才能让它工作? 具体在哪里需要vnet选项? 在监狱里 Poudriere 是在还是 Poudriere 创建的监狱里?

它在 poudriere jail 的配置中。 我这样做了。

对于 /etc/rc.conf:

cloned_interfaces="bridge0"
ifconfig_bridge0="addm ix0 up"

然后对于监狱配置:

$ sudo iocage set vnet=on pkg01
$ sudo iocage set ip4_addr="vnet0|10.55.0.29/24" pkg01
$ sudo iocage set ip6_addr="vnet0|[redacted]:23/64" pkg01

我将在下周左右发布一篇博文。

只是想跟进我在阅读本文后运行 12.1-RELEASE-p7 时所做的更新:

“这也意味着当一个被监禁的守护进程连接到“环回地址”上的端口时,它实际上是连接到监狱的外部 IP 地址。”
Lucas, Michael W. FreeBSD Mastery: Jails(IT Mastery Book 15)

将 poudriere.conf 中的 LOIP4 设置为 jail 的 ip4_addr 允许 ruby​​ 编译。

就我而言:
# iocage 获取 ip4_addr poudriere
lo1|192.168.10.100

# grep LOIP4 /usr/local/etc/poudriere.conf
LOIP4=192.168.10.100

此页面是否有帮助?
0 / 5 - 0 等级