Bug 1305688 - oo-accept-broker incorrectly parses MONGO_HOST_PORT individual host and ports
oo-accept-broker incorrectly parses MONGO_HOST_PORT individual host and ports
Status: CLOSED ERRATA
Product: OpenShift Container Platform
Classification: Red Hat
Component: Unknown (Show other bugs)
2.2.0
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Vu Dinh
Johnny Liu
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-08 16:54 EST by Dave Sullivan
Modified: 2016-03-22 12:54 EDT (History)
5 users (show)

See Also:
Fixed In Version: openshift-origin-broker-util-1.37.5.2-1.el6op
Doc Type: Bug Fix
Doc Text:
Cause: oo-accept-broker doesn't filter the single or double quote from MONGO_HOST_PORT variable before parsing it. Consequence: The individual host and port parsed from MONGO_HOST_PORT contain unwanted quote characters. When oo-accept-broker attempts to access to broker using those information, it fails. As a result, it generates a false result that oo-accept-broker fails. Fix: The unwanted quote characters from MONGO_HOST_PORT will be removed before parsing. Result: The oo-accept-broker command now has correct information about broker's host and port to determine if the broker is accessible.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-03-22 12:54:13 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Dave Sullivan 2016-02-08 16:54:49 EST
Description of problem:

The validation of mongo replicant fails but because the parsing is incorrect

[root@acme001 ~]# grep "MONGO_HOST" /etc/openshift/broker.conf
# Eg: MONGO_HOST_PORT="<host1:port1>,<host2:port2>..."
#MONGO_HOST_PORT="localhost:27017"
MONGO_HOST_PORT="acme001.acme.org:27017,acme002.acme.org:27017"

Because of the quotes the host and port settings do not remove the " so the test fails

timeout 1 bash -c "cat </dev/null > /dev/tcp/$host/$port" &> /dev/null
 
By changing /usr/sbin/oo-accept-node from
 
      host=$(echo $mongo_replicant | cut -d: -f1)
      port=$(echo $mongo_replicant | cut -d: -f2)
 
      to
 
        host=$(echo $mongo_replicant | cut -d: -f1 | tr -d '"')
        port=$(echo $mongo_replicant | cut -d: -f2 | tr -d '"')

And the the test passes as the host/port don't contain any quotes


Version-Release number of selected component (if applicable):

openshift-origin-broker-util-1.36.2.2-1.el6op.noarch
Comment 2 openshift-github-bot 2016-02-16 15:39:51 EST
Commit pushed to master at https://github.com/openshift/origin-server

https://github.com/openshift/origin-server/commit/a9bcb953f3ec4d822b561e7fc22f4ddba5aa40c1
Bug 1305688 - oo-accept-broker incorrectly parses MONGO_HOST_PORT

The validation of mongo replicant fails as the code in oo-accept-broker
that is responsible to parse MONGO_HOST_PORT is not working correctly
as it fails to remove unwanted quote characters in the variable.

This commit fixes the code that is parsing the MONGO_HOST_PORT to remove
the quote characters before performing the task. As a result, individual
ports and hosts from MONGO_HOST_PORT are now parsed correctly.

Bug 1305688
Link <https://bugzilla.redhat.com/show_bug.cgi?id=1305688>

Signed-off-by: Vu Dinh <vdinh@redhat.com>
Comment 6 Johnny Liu 2016-02-26 06:39:44 EST
Verified this bug with openshift-origin-broker-util-1.37.5.2-1.el6op.noarch, and PASS.


# grep "MONGO_HOST" /etc/openshift/broker.conf
# Eg: MONGO_HOST_PORT="<host1:port1>,<host2:port2>..."
MONGO_HOST_PORT="localhost:27017"


# oo-accept-broker -v
<--snip-->
INFO: checking Mongo host connectivity
INFO: Connected to Mongo host: "localhost:27017"
<--snip-->
PASS
Comment 7 Johnny Liu 2016-02-26 07:09:20 EST
Actually the PR is not landed into OSE puddle.

# rpm -qf /usr/sbin/oo-accept-broker
openshift-origin-broker-util-1.37.5.2-1.el6op.noarch


# oo-accept-broker 
+ verbose 'checking Mongo host connectivity'
+ '[' -n '' ']'
++ grep -e '^MONGO_HOST_PORT=' /etc/openshift/broker.conf
++ cut -d= -f2
+ MONGO_HOST='"192.168.0.143:27017"'
+ [[ "192.168.0.143:27017" == *,* ]]
++ echo '"192.168.0.143:27017"'
++ cut -d: -f1
+ host='"192.168.0.143'
++ echo '"192.168.0.143:27017"'
++ cut -d: -f2
+ port='27017"'
+ timeout 1 bash -c 'cat </dev/null > /dev/tcp/"192.168.0.143/27017"'
+ '[' 0 '!=' 0 ']'
+ verbose 'Connected to Mongo host: "192.168.0.143:27017"'
+ '[' -n '' ']'
+ set +x
PASS


Interestingly, when I run testing using "localhost", no any error is reported in comment6, so pls ignore comment 6.

After I modify "localhost" to "192.168.0.143", the issue is reproduced.
Comment 8 Rory Thrasher 2016-03-03 17:43:49 EST
QE,

Sorry for the confusion earlier, this bug got put on the errata a bit too soon.  Can we retest using the latest puddle and the instructions from comment #5? Thank you.

Puddle: http://etherpad.corp.redhat.com/puddle-2-2-2016-02-19
Comment 9 Johnny Liu 2016-03-06 21:57:54 EST
Verified this bug with openshift-origin-broker-util-1.37.5.3-1.el6op.noarch, and PASS.


# grep "MONGO_HOST" /etc/openshift/broker.conf
# Eg: MONGO_HOST_PORT="<host1:port1>,<host2:port2>..."
MONGO_HOST_PORT="192.168.0.143:27017,localhost:27017"



# oo-accept-broker
+ verbose 'checking Mongo host connectivity'
+ '[' -n '' ']'
++ grep -e '^MONGO_HOST_PORT=' /etc/openshift/broker.conf
++ cut -d= -f2
+ MONGO_HOST='"192.168.0.143:27017,localhost:27017"'
+ [[ "192.168.0.143:27017,localhost:27017" == *,* ]]
+ unreachable_count=0
+ replica_count=0
++ echo '"192.168.0.143:27017,localhost:27017"'
++ sed 's/,/ /g'
+ for mongo_replicant in '$(echo $MONGO_HOST | sed s/,/\ /g)'
+ (( replica_count++ ))
++ echo '"192.168.0.143:27017'
++ tr -d ''\''"'
++ cut -d: -f1
+ host=192.168.0.143
++ echo '"192.168.0.143:27017'
++ tr -d ''\''"'
++ cut -d: -f2
+ port=27017
+ timeout 1 bash -c 'cat </dev/null > /dev/tcp/192.168.0.143/27017'
+ '[' 0 '!=' 0 ']'
+ verbose 'Connected to Mongo replicant: "192.168.0.143:27017'
+ '[' -n '' ']'
+ for mongo_replicant in '$(echo $MONGO_HOST | sed s/,/\ /g)'
+ (( replica_count++ ))
++ cut -d: -f1
++ tr -d ''\''"'
++ echo 'localhost:27017"'
+ host=localhost
++ echo 'localhost:27017"'
++ tr -d ''\''"'
++ cut -d: -f2
+ port=27017
+ timeout 1 bash -c 'cat </dev/null > /dev/tcp/localhost/27017'
+ '[' 0 '!=' 0 ']'
+ verbose 'Connected to Mongo replicant: localhost:27017"'
+ '[' -n '' ']'
+ '[' 0 == 2 ']'
+ verbose 'At least one Mongo replicant is listening on the specified host and port.'
+ '[' -n '' ']'
+ set +x
PASS
Comment 11 errata-xmlrpc 2016-03-22 12:54:13 EDT
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/RHSA-2016-0489.html

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