为什么 sensu-client 无法在 Travis 上的 docker 中启动?

为什么 sensu-client 无法在 Travis 上的 docker 中启动?

这个 Ansible 角色已创建并这个 .travis.yml已用作示例来测试该角色。除 sensu-client 外,所有服务均能启动。

尝试解决问题

为了解决问题向 travis 添加了一个调试步骤。构建完成时抛出了以下错误:

The command "sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)

" exited with 1.

0.07s$ sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm sudo systemctl status sensu-client.service -l

● sensu-client.service - LSB: Sensu monitoring framework client

   Loaded: loaded (/etc/rc.d/init.d/sensu-client)

   Active: failed (Result: exit-code) since Mon 2016-08-08 00:18:20 UTC; 131ms ago

     Docs: man:systemd-sysv-generator(8)

  Process: 1534 ExecStart=/etc/rc.d/init.d/sensu-client start (code=exited, status=1/FAILURE)

Aug 08 00:18:19 c6354976113c systemd[1]: Starting LSB: Sensu monitoring framework client...

Aug 08 00:18:19 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: line 71: /etc/init.d/functions: No such file or directory

Aug 08 00:18:19 c6354976113c sensu-client[1534]: Starting sensu-client/etc/init.d/sensu-service: line 79: daemon: command not found

Aug 08 00:18:20 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: line 88: echo_failure: command not found

Aug 08 00:18:20 c6354976113c systemd[1]: sensu-client.service: control process exited, code=exited status=1

Aug 08 00:18:20 c6354976113c systemd[1]: Failed to start LSB: Sensu monitoring framework client.

Aug 08 00:18:20 c6354976113c systemd[1]: Unit sensu-client.service entered failed state.

Aug 08 00:18:20 c6354976113c systemd[1]: sensu-client.service failed.

当 ansible 角色部署在远程系统上时,sensu-client 会启动,但它在 Travis 上会失败,尽管其他服务可以启动。

答案1

简洁的

initscripts缺少软件包。这是在将本地系统上的文件与 Travis 使用的 docker 容器中的文件进行比较后发现的。/etc/init.d查询后,/etc/init.d/functions清楚了需要安装哪个软件包。

详细

似乎缺少文件/etc/init.d,即:

Aug 08 00:18:19 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: 
line 71: /etc/init.d/functions: No such file or directory

是真的吗?为了检查是否添加了另一个调试步骤:ls /etc/init.d结果如下:

$ sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ls /etc/init.d

README  sensu-api  sensu-client  sensu-server  sensu-service  uchiwa

functions确实失踪了。这个帖子表示initscripts需要安装。当该包已添加到 Dockerfile然后构建再次运行它成功了

相关内容