New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added replicaset name to bigchaindb config #1063
Conversation
Current coverage is 96.76% (diff: 100%)
|
It now initializes the replica set with the name provided by the bigchaindb config file. Fixed tests.
This way we are sure that a replica set exists when we return a connection.
port=bigchaindb.config['database']['port']) | ||
_check_replica_set(conn) | ||
config = {'_id': bigchaindb.config['database']['replicaset'], | ||
'members': [{'_id': 0, 'host': 'localhost:27017'}]} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder: should we get the host and port from the config, for cases where the host and port differ from defaults?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
while True: | ||
logs = conn.admin.command('getLog', 'rs')['log'] | ||
if any('database writes are now permitted' in line for line in logs): | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indentation is one tab off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copypasta failed
initialize_replica_set() | ||
self.connection = MongoClient(self.host, self.port, | ||
replicaset=self.replicaset) | ||
except errors.ConnectionFailure as exc: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can discard the exc
as it is not used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only looked at the docs changes and they look okay to me.
resolves #1056
This pr adds
replicaset
tobigchaindb.config
.Also updated the mongodb connection initialization to connect to a replica set, and moved the
initialize_replica_set
intomongodb.connection
. The reason for this is that the replicaset needs to be initialized before we even try to setup aMongoDBConnection