Bug 824894

Summary: [RFE] Option for pulp-migrate to wait for connection
Product: [Retired] Pulp Reporter: Lukas Zapletal <lzap>
Component: z_otherAssignee: Jay Dobies <jason.dobies>
Status: CLOSED WONTFIX QA Contact: Preethi Thomas <pthomas>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 1.2.0CC: shane.seymour
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-11-27 15:04:09 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:

Description Lukas Zapletal 2012-05-24 14:18:29 UTC
In Katello installer, we start mongodb and then execute pulp-migrate. On some machines, maybe thanks to systemd, mongodb starts very fast, but TCP socket is not ready. So our Puppet fails with

pymongo.errors.AutoReconnect: could not connect to localhost:27017: [Errno 111] Connection refused

We would like to have a new option that would force pulp-migrate to wait until connection is estabilished. Something like (pseudo code):

# the db connection and auditing need to be initialied before any further
# imports since the imports execute initialization code relying on the
# db/auditing to be setup
retry = 10
while retry > 0:
    except pymongo.errors.AutoReconnect:
        if retry == 1:
        print "Waiting for connection..."
        retry = retry - 1

But nicer ;-) Thanks!

Comment 1 Lukas Zapletal 2012-05-24 14:43:33 UTC
Oh I just noticed when mongo starts for the first time, it is preallocating some big data file. That is the reason why it takes so long. Maybe we wont need the patch in pulp, I just need to find a way to let mongo allocate it using a manual command or something.

Will ask on the list.

Comment 2 Shane Seymour 2012-10-31 03:45:50 UTC
This is just a me-too entry to say that I've seen this after installing pulp (today) and trying to set it up:

# service pulp-server init
Starting mongod:                                           [  OK  ]
Traceback (most recent call last):
  File "/usr/bin/pulp-migrate", line 19, in <module>
    from pulp.server.db.migrate import script
  File "/usr/lib/python2.6/site-packages/pulp/server/db/migrate/script.py", line
 26, in <module>
  File "/usr/lib/python2.6/site-packages/pulp/server/db/connection.py", line 47,
 in initialize
    _connection = pymongo.Connection(seeds)
  File "/usr/lib64/python2.6/site-packages/pymongo/connection.py", line 381, in 
  File "/usr/lib64/python2.6/site-packages/pymongo/connection.py", line 659, in 
    raise AutoReconnect(', '.join(errors))
pymongo.errors.AutoReconnect: could not connect to localhost:27017: [Errno 111] 
Connection refused

Run it again after checking that something was now listening on port 27017 using netstat -an and it works:

# service pulp-server init
removing persisted tasks
database migration to version 41 complete

Comment 3 Lukas Zapletal 2012-11-05 11:23:31 UTC
@Shane - I have found MongoDB 1.8+ can preallocate journals (3 gigs) during the first startup. You can do this manually using dd command, search mongo wiki.

Comment 4 Jay Dobies 2012-11-27 15:04:09 UTC
In 2.x, pulp-server has been removed entirely. The replacement for pulp-migrate, now called pulp-manage-db, no longer attempts to start mongo. Starting the necessary servers is a prerequisite of running that script, thereby removing this issue.

Closing this as "WONTFIX" as it was aligned to 1.2 and will not be changed there.