Bug 824894 - [RFE] Option for pulp-migrate to wait for connection
[RFE] Option for pulp-migrate to wait for connection
Product: Pulp
Classification: Community
Component: z_other (Show other bugs)
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Jay Dobies
Preethi Thomas
: Triaged
Depends On:
  Show dependency treegraph
Reported: 2012-05-24 10:18 EDT by Lukas Zapletal
Modified: 2012-11-27 10:04 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2012-11-27 10:04:09 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Lukas Zapletal 2012-05-24 10:18:29 EDT
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 10:43:33 EDT
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-30 23:45:50 EDT
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 06:23:31 EST
@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 10:04:09 EST
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.

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