Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1112840

Summary: mongodb init script status check does not work with bind_ip = 0.0.0.0
Product: Red Hat OpenStack Reporter: Flavio Percoco <fpercoco>
Component: mongodbAssignee: Flavio Percoco <fpercoco>
Status: CLOSED ERRATA QA Contact: Yurii Prokulevych <yprokule>
Severity: medium Docs Contact:
Priority: high    
Version: 4.0CC: adahms, ajeain, chrobert, fpercoco, jjozwiak, sclewis, scohen, slong, yeylon
Target Milestone: z6Keywords: ZStream
Target Release: 4.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: mongodb-2.4.6-8.el6ost Doc Type: Bug Fix
Doc Text:
Previously, MongoDB's init script would fail when bind_ip was set to 0.0.0.0. This would prevent the mongodb service from listening on all addresses, resulting in the service being bound to 127.0.0.1. This issue has now been fixed, and mongodb can now be bound to specific IP addresses or none (0.0.0.0).
Story Points: ---
Clone Of: 1112416 Environment:
Last Closed: 2015-04-23 13:03:44 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1112416    
Bug Blocks:    

Comment 3 Amit Ugol 2014-10-11 13:29:04 UTC
tested with mongodb-server-2.4.6-5.el6ost.x86_64

following the steps to reproduce:

# grep 0.0.0.0 /etc/mongodb.conf 
bind_ip = 0.0.0.0

after restarting the service:

# netstat -apn | grep mongod
tcp        0      0 127.0.0.1:28017             0.0.0.0:*                   LISTEN      23278/mongod 

However there is a syntax error at line 163 of /etc/init.d/mongod which would always cause service mongod status to fail:
[ -z "$a" || "$a" = "0.0.0.0" ] && a=127.0.0.1
should probably be ?
[ -z "$a" ] || [ "$a" = "0.0.0.0" ] && a=127.0.0.1

Comment 4 Amit Ugol 2014-10-19 11:18:29 UTC
failed for the same reason as https://bugzilla.redhat.com/show_bug.cgi?id=1112416#c8

was fixed in rhos 5.

Comment 8 Yurii Prokulevych 2015-04-20 08:53:32 UTC
# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.6 (Santiago)
# rpm -qa | grep mongodb
mongodb-2.4.6-8.el6ost.x86_64



[Tests with BIND_IP = 0.0.0.0 ]
# grep '^bind_ip' /etc/mongodb.conf
bind_ip = 0.0.0.0

# /etc/init.d/mongod status
mongod (pid  18524) is running...
listening on 0.0.0.0:27017
connection test successful

# echo $?
0

# service mongod status
mongod (pid  18524) is running...
listening on 0.0.0.0:27017
connection test successful
# echo $?
0

# service mongod restart
Stopping mongod:                                           [  OK  ]
Starting mongod:                                           [  OK  ]
Waiting for mongod to become available:                    [  OK  ]
# echo $?
0 


# /etc/init.d/mongod stop
Stopping mongod:                                           [  OK  ]
# /etc/init.d/mongod status
mongod is stopped


[Some regrssion with specified IP and localhost]

[TEST WITH BIND_IP]

# grep '^bind_ip' /etc/mongodb.conf
bind_ip = 10.35.101.10

# /etc/init.d/mongod start
Starting mongod:                                           [  OK  ]
Waiting for mongod to become available:                    [  OK  ]
# /etc/init.d/mongod status
mongod (pid  31552) is running...
listening on 10.35.101.10:27017
connection test successful
# echo $?
0
# /etc/init.d/mongod stop
Stopping mongod:                                           [  OK  ]
# echo $?
0



# service mongod start
Starting mongod:                                           [  OK  ]
Waiting for mongod to become available:                    [  OK  ]
# echo $?
0
# service mongod status
mongod (pid  31678) is running...
listening on 10.35.101.10:27017
connection test successful
# echo $?
0

# /etc/init.d/mongod restart
Stopping mongod:                                           [  OK  ]
Starting mongod:                                           [  OK  ]
Waiting for mongod to become available:                    [  OK  ]
# echo $?
0

# /etc/init.d/mongod status
mongod (pid  473) is running...
listening on 10.35.101.10:27017
connection test successful

# echo $?
0
# service mongod stop
Stopping mongod:                                           [  OK  ]
# echo $?
0

[TESTS WITH LOCALHOST]
# grep '^bind_ip' /etc/mongodb.conf
bind_ip = 127.0.0.1
# /etc/init.d/mongod status
mongod is stopped
# /etc/init.d/mongod start
Starting mongod:                                           [  OK  ]
Waiting for mongod to become available:                    [  OK  ]
# echo $?
0
# /etc/init.d/mongod status
mongod (pid  31900) is running...
listening on 127.0.0.1:27017
connection test successful
# echo $?
0
# /etc/init.d/mongod stop
Stopping mongod:                                           [  OK  ]
# echo $?
0

# service mongod start
Starting mongod:                                           [  OK  ]
Waiting for mongod to become available:                    [  OK  ]
# echo $?
0
# service mongod status
mongod (pid  32028) is running...
listening on 127.0.0.1:27017
connection test successful
# echo $?
0
# service mongod restart
Stopping mongod:                                           [  OK  ]
Starting mongod:                                           [  OK  ]
Waiting for mongod to become available:                    [  OK  ]
# echo $?
0
# service mongod status
mongod (pid  1205) is running...
listening on 127.0.0.1:27017
connection test successful
# echo $?
0

# service mongod stop
Stopping mongod:                                           [  OK  ]
# echo $?
0

Comment 10 errata-xmlrpc 2015-04-23 13:03:44 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-0885.html