-
Notifications
You must be signed in to change notification settings - Fork 13.8k
[FLINK-31234][kubernetes] Add an option to redirect stdout to log dir. #22138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9c89077 to
60f39ee
Compare
wangyang0918
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR looks pretty good to me. And I have verified with standalone mode. It works well. The stdout and stderr could be redirected to individual files. After then we could access the stdout in the Flink webUI.
echo "env.std.redirect: true" >>conf/flink-conf.yaml
./bin/jobmanager.sh start-foreground
./bin/taskmanager.sh start-foreground
| */ | ||
| @SuppressWarnings("unused") | ||
| public static final ConfigOption<Boolean> FLINK_STD_REDIRECT = | ||
| ConfigOptions.key("env.std.redirect") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the key name could be env.stdout-err.redirect-to-file. It is more explicit.
| FLINK_ENV_JAVA_OPTS=$(eval echo ${FLINK_ENV_JAVA_OPTS}) | ||
|
|
||
| if [ "${STD_REDIRECT}" == "true" ]; then | ||
| # disable console appender to avoid redundant logs in log file and out file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We never have redundant logs in log file. Right?
Here is only to avoid the redundant logs in out file.
|
@wangyang0918 , Thanks for your review. comments addressed. And verified by running on Kubernetes. |
wangyang0918
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for merging.
|
|
||
| if [ "${STD_REDIRECT_TO_FILE}" == "true" ]; then | ||
| # disable console appender to avoid redundant logs in out file | ||
| log_setting=("-Dconsole.log.level=OFF" "${log_setting[@]}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
进过验证-Dconsole.log.level=OFF 对于log4j来说似乎不能把appender.console的日志禁用🤔
那.out不就包含了log输出和sout吗,这样的话感觉 .log 和 .out两个文件没有同时存在的必要了。
或者三个文件同时存在的话,是不是可以把.out 移除Console的输出
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reporting this.
This option works fine for disabling console log output in my case.
Could you provide your log4j.properties file and the steps to reproduce this issue?
|
@huwh 感谢回复,环境如下: apiVersion: flink.apache.org/v1beta1
kind: FlinkDeployment
metadata:
name: basic
spec:
image: flink:1.18.1-scala_2.12
flinkVersion: v1_18
ingress:
className: "nginx"
template: "{{name}}.fo.xyuqing.com" # 引号必须有
podTemplate:
spec:
containers:
- name: flink-main-container
ports:
- name: metrics
containerPort: 9249
protocol: TCP
env:
- name: TZ # 设置容器运行的时区
value: Asia/Shanghai
flinkConfiguration:
taskmanager.numberOfTaskSlots: "2"
env.stdout-err.redirect-to-file: "true"
metrics.reporter.prom.factory.class: org.apache.flink.metrics.prometheus.PrometheusReporterFactory
serviceAccount: flink
jobManager:
resource:
cpu: 1
memory: 2G
taskManager:
resource:
cpu: 1
memory: 2G
job:
jarURI: local:///opt/flink/examples/streaming/StateMachineExample.jar
parallelism: 2
upgradeMode: stateless
我的意思是虽然 |
@xiaows08 This is because flink-kubernetes-operator uses its log4j-console.properties, which does not support the console appender filtering function. Currently, flink-kubernetes-operator does not recommend enable env.stdout-err.redirect-to-file, which does cause log duplication. |




What is the purpose of the change
Add an option for redirecting stdout/stderr to files. When this is enabled.
Of course, this option is false by default.
Brief change log
Verifying this change
Does this pull request potentially affect one of the following parts:
@Public(Evolving): (no)Documentation