tcsetpgrp failed重新编译tini

时间:2022-07-22
本文章向大家介绍tcsetpgrp failed重新编译tini,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

1 Overview

在启动 Spark Operator 的时候出现了一个意想不到的问题。

[root@sholdmix01node1 /data/runzhliu/spark]# kubectl log  -n kube-system spark-sparkoperator-86f6c889cd-ggbmc
log is DEPRECATED and will be removed in a future version. Use logs instead.
++ id -u
+ myuid=185
++ id -g
+ mygid=0
+ set +e
++ getent passwd 185
+ uidentry=
+ set -e
+ echo 185
185
0

+ echo 0
+ echo
+ [[ -z '' ]]
+ [[ -w /etc/passwd ]]
+ echo '185:x:185:0:anonymous uid:/opt/spark:/bin/false'
+ exec /usr/bin/tini -s -- /usr/bin/spark-operator
[FATAL tini (9)] tcsetpgrp failed: Permission denied

因为本人在腾讯,这是因为开发环境的 tlinux 的问题,导致 tini 出错了。寻找了很久,也没找到 特别有效的信息,于是查看一下 tini 的源码,看看 这个 错误是如何产生的。

2 tini 源码

大家可以看到这行代码,错误信息就是由他打印的。

// Doing it in the child process avoids a race condition scenario
// if Tini is calling Tini (in which case the grandparent may make the
// parent the foreground process group, and the actual child ends up...
// in the background!)
if (tcsetpgrp(STDIN_FILENO, getpgrp())) {
	if (errno == ENOTTY) {
		PRINT_DEBUG("tcsetpgrp failed: no tty (ok to proceed)");
	} else if (errno == ENXIO) {
		// can occur on lx-branded zones
		PRINT_DEBUG("tcsetpgrp failed: no such device (ok to proceed)");
	} else {
		PRINT_FATAL("tcsetpgrp failed: %s", strerror(errno));
		return 1;
	}
}

可以直接把这段代码注释掉,然后重新编译 cmake . && make

3 Summary

将重新编译后的 tini 替换原来镜像的 tini 即可。