Bug 1202513 - watchman jboss plugin fails parsing invalid byte sequence in UTF-8
Summary: watchman jboss plugin fails parsing invalid byte sequence in UTF-8
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Containers
Version: 2.2.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: ---
Assignee: Brenton Leanhardt
QA Contact: libra bugs
URL:
Whiteboard:
Depends On: 1191681
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-03-16 19:06 UTC by Brenton Leanhardt
Modified: 2015-04-06 17:06 UTC (History)
10 users (show)

Fixed In Version: openshift-origin-node-util-1.34.4.1-1.el6op
Doc Type: Bug Fix
Doc Text:
Watchman's JBoss plug-in would previously fail with an "invalid byte sequence in UTF-8" error if a JBoss log contained ISO-8859-1 bytes which were not valid UTF-8, such as the string "\xe9". This was due to the plug-in opening files in a way that only worked as long as the byte sequences were valid UTF-8. This bug fix updates the plug-in to instead open files in binary mode, which supports regex matching on all encodings. As a result, the plug-in no longer produces these errors.
Clone Of: 1191681
Environment:
Last Closed: 2015-04-06 17:06:49 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2015:0779 0 normal SHIPPED_LIVE Red Hat OpenShift Enterprise 2.2.5 bug fix and enhancement update 2015-04-06 21:05:45 UTC

Description Brenton Leanhardt 2015-03-16 19:06:12 UTC
+++ This bug was initially created as a clone of Bug #1191681 +++

Description of problem:

Watchman's jboss plugin fails with "invalid byte sequence in UTF-8" if a jboss log contains, ISO-8859-1 bytes which are not valid UTF-8 (such as \xe9).

Version-Release number of selected component (if applicable):
openshift-origin-node-util-1.33.4-1.el6oso.noarch

How reproducible:
Always

Steps to Reproduce:
1. create a jbossews app
2. echo -e '\xe9' >> ~/app-root/logs/jbossews.log

Actual results:
watchman will event print something like this to /var/log/messages:
Feb  9 17:41:38 ex-std-nodeXXX watchman[217144]: Unhandled exception (invalid byte sequence in UTF-8) from Watchman plugin #<JbossPlugin:0x00000002c277a0>: invalid byte sequence in UTF-8

Expected results:
watchman should ignore invalid characters in the log file.

Additional info:

This has been dealt with two different ways in the past.  It was first fixed in https://bugzilla.redhat.com/show_bug.cgi?id=1023576 by treating the file as binary (opening it with 'rb').

When the code was refactored and moved into origin-server, the 'b' was lost, and the bug came up again as https://bugzilla.redhat.com/show_bug.cgi?id=1059804

This time, it was fixed by opening the file with "r:utf-8", but that only works as long as all of the byte sequences are valid utf-8, which we cannot control.  I'd suggest either going back to "rb", or doing something like:

File.open(log, 'r:utf-8').each_line do |event|
    next unless event.valid_encoding? && event =~ / java.lang.OutOfMemoryError/
    ...

In my tests, this is about 15-20% more expensive than grep, but it works.

--- Additional comment from Dan Mace on 2015-02-12 12:53:34 EST ---

https://github.com/openshift/origin-server/pull/6073

--- Additional comment from Meng Bo on 2015-02-13 02:45:18 EST ---

Checked on devenv_5430, after insert the invalid ISO-8859-1 string "\xe9" to the jboss log, the watchman will not report unhandled exception and still works well on the existing features.

Move bug to verified.

Comment 3 Anping Li 2015-03-17 06:13:07 UTC
Verified and pass on puddle-2-2-2015-03-16
1) Create jbossews and jbosseap6 application

add utf-8 code & java.lang.OutOfMemoryError/ in jbossews.log and jbosseap.log
For example:
2015/03/17 14:11:14,582 INFO é
2015/03/17 14:11:14,582 INFO ¿¿¿¿¿
2015/03/17 14:11:14,582 INFO java.lang.OutOfMemoryError

2)check /var/log/message. jbosseap and jbossews were restarted and no exception

Mar 17 14:05:36 node1 watchman[1447]: Gears: 5, Memory: 41112, Plugin: all, Symbols: 10674, Objects: 182281
Mar 17 14:05:56 node1 watchman[1447]: Gears: 5, Memory: 41112, Plugin: all, Symbols: 10674, Objects: 182281
Mar 17 14:06:37 node1 watchman[1447]: watchman restarted user 5507ac314add71c6dc0000a7: application jbosseap6 (retries: 0)
Mar 17 14:06:37 node1 watchman[1447]: Gears: 5, Memory: 41116, Plugin: all, Symbols: 10676, Objects: 182281
Mar 17 14:06:57 node1 watchman[1447]: gear 5507ac314add71c6dc0000a7 (re)started under retry_delay (1/480)
Mar 17 14:07:06 node1 watchman[1447]: watchman restarted user 5507c11f4add7185960000b2: application jbossews (retries: 0)

Comment 5 errata-xmlrpc 2015-04-06 17:06:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0779.html


Note You need to log in before you can comment on or make changes to this bug.