-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
container logs should be escaped when printed #2751
Conversation
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.
@wjiec Thank you for looking into this issue!
internal/dao/pod.go
Outdated
@@ -380,8 +381,8 @@ func readLogs(ctx context.Context, wg *sync.WaitGroup, stream io.ReadCloser, out | |||
r := bufio.NewReader(stream) | |||
for { | |||
var item *LogItem | |||
if bytes, err := r.ReadBytes('\n'); err == nil { | |||
item = opts.ToLogItem(bytes) | |||
if line, err := r.ReadString('\n'); err == nil { |
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.
@wjiec Given we are dealing with logs, I think there will be additional allocations converting bytes->string->bytes. Perhaps we should regex directly the bytes vs hitting the extra allocations?
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.
@derailed I've thought about this, if regular expression matching is done directly on the bytes it would require copying the code out of the tview, which I think might be a bit repetitive, and could also leave a hidden problem if the tview updates this regular expression afterwards. I chose the safer out of the two possible methods.
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 Jayson! I understand. We are however using a fork and we can control changes if they occurred but that would require a strategy change for region and color tags which is unlikely. On the other hand we're dealing with lots of gc pressure. I think we could perhaps intro a one liner tview.EscapeBytes in the fork?
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.
@derailed Thank you for your reply, indeed, it is the best way!
b5d6d4c
to
6ce7e76
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.
@wjiec Awesome! Thank you Jayson!!
@derailed Oops, I'm having problems with the implementation in |
* container logs should be escaped when printed * reduce additional memory allocation * upgrade deps and move escape to tview
this pr fixes #2746.