-
Notifications
You must be signed in to change notification settings - Fork 970
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
Fix console log character encoding #4044
Conversation
2ee601d
to
79b9e5d
Compare
79b9e5d
to
a99d30d
Compare
@@ -166,7 +166,8 @@ private void runBuild(BuildSettings buildSettings) { | |||
buildConsole = new ConsoleOutputTransmitter( | |||
new RemoteConsoleAppender( | |||
urlService.prefixPartialUrl(buildSettings.getConsoleUrl()), | |||
httpService) | |||
httpService, | |||
getSystemEnvironment().consoleLogCharsetAsCharset()) |
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 would be set at the server side not agent. The charset that was passed along from the server to the agent needs to be passed along to the Console appender
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 needs to be handled for the BuildCompose workflow. We should be able to pass along the encoding from server as a part of BuildSettings
instead of using getSystemEnvironment().consoleLogCharsetAsCharset()
.
f9ea049
to
8ae3f7f
Compare
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.
Did a quick round of testing for this since I wasn't sure if console logs over websocket will work out of the box as far as encoding is concerned. It doesn't. Haven't debugged to see what exactly is the issue with that though.
When I say it doesn't work, I meant the encoding gets screwed up during the transmission. There might be some other issues with transmission of logs over websockets, I wasn't talking about them.
@@ -212,6 +212,6 @@ public void setProperty(JobIdentifier jobIdentifier, Property property) { | |||
public ConsoleOutputTransmitter createConsoleOutputTransmitter(JobIdentifier jobIdentifier, | |||
AgentIdentifier agentIdentifier) { | |||
String consoleUrl = urlService.getUploadUrlOfAgent(jobIdentifier, getConsoleOutputFolderAndFileNameUrl()); | |||
return new ConsoleOutputTransmitter(new RemoteConsoleAppender(consoleUrl, httpService)); | |||
return new ConsoleOutputTransmitter(new RemoteConsoleAppender(consoleUrl, httpService, new SystemEnvironment().consoleLogCharsetAsCharset())); |
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.
Since BuildWork
already contains the charset from server, we should just be able to pass it here.
@@ -166,7 +166,8 @@ private void runBuild(BuildSettings buildSettings) { | |||
buildConsole = new ConsoleOutputTransmitter( | |||
new RemoteConsoleAppender( | |||
urlService.prefixPartialUrl(buildSettings.getConsoleUrl()), | |||
httpService) | |||
httpService, | |||
getSystemEnvironment().consoleLogCharsetAsCharset()) |
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 needs to be handled for the BuildCompose workflow. We should be able to pass along the encoding from server as a part of BuildSettings
instead of using getSystemEnvironment().consoleLogCharsetAsCharset()
.
4b62934
to
2a43292
Compare
2a43292
to
eb3087d
Compare
71cfe71
to
5971481
Compare
@@ -83,6 +84,7 @@ private CommandLine createCommandLine(String cmd) { | |||
} else { | |||
commandLine = CommandLine.createCommandLine(cmd); | |||
} | |||
commandLine.withEncoding(new SystemEnvironment().consoleLogCharset()); |
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.
@jyotisingh — we'd likely need to inject the charset to all BuildCommandExecutor
impls, or add it to BuildSession
to make it available to all executors.
Thoughts?
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.
I prefer adding it to the BuildSession. One way would be to pass along the charset with BuildSettings and then use it to construct the BuildSession
. That way in future too if any other CommandExecutor needs access to commandline, it could just get hold of the charset from BuildSession
7ad694a
to
6c8a9c8
Compare
6c8a9c8
to
dab2c7c
Compare
Charset is determined on the server using the system property `go.console.log.charset`.
For testing this PR, create a file ( Use the following config.xml snippet: <pipeline name="up42">
<materials>
<git url="test-repo" />
</materials>
<stage name="up42_stage">
<jobs>
<job name="up42_job">
<tasks>
<exec command="bash" args="-c 'while true; do cat /tmp/unicode.txt; sleep 1; done'" />
</tasks>
</job>
</jobs>
</stage>
</pipeline> On 18.1 of GoCD server and agent:
On latest (experimental) GoCD
On latest (experimental) GoCD
|
Tested the above steps
|
It works for me.
|
Fixes #3926, #3442