Bug 824894 - [RFE] Option for pulp-migrate to wait for connection
Summary: [RFE] Option for pulp-migrate to wait for connection
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Pulp
Classification: Retired
Component: z_other
Version: 1.2.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
: ---
Assignee: Jay Dobies
QA Contact: Preethi Thomas
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-05-24 14:18 UTC by Lukas Zapletal
Modified: 2012-11-27 15:04 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-11-27 15:04:09 UTC
Embargoed:


Attachments (Terms of Use)

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:
    try:
        connection.initialize()
    except pymongo.errors.AutoReconnect:
        if retry == 1:
            raise
        print "Waiting for connection..."
        time.sleep(2)
        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>
    connection.initialize()
  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 
__init__
    self.__find_node()
  File "/usr/lib64/python2.6/site-packages/pymongo/connection.py", line 659, in 
__find_node
    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.


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