Ask Your Question
0

what's the role of slave_connection in neutron.conf

asked 2014-01-07 06:13:11 -0500

In neutron.conf, for section [database], there's two connection as below: ===================[database]================================ [database]

This line MUST be changed to actually run the plugin.

Example:

connection = mysql://root:pass@127.0.0.1:3306/neutron

Replace 127.0.0.1 above with the IP address of the database used by the

main neutron server. (Leave it as is if the database runs on this host.)

connection = sqlite://

The SQLAlchemy connection string used to connect to the slave database

# slave_connection =

What's the role of slave_connection ?

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted
0

answered 2014-01-08 03:29:37 -0500

aji-zqfan gravatar image

you can read this wiki to get a general knowledge: https://wiki.openstack.org/wiki/Slave_usage (https://wiki.openstack.org/wiki/Slave...)

the sql connection/slave_connection config opt is used by oslo sqlalchemy session module[0], not neutron directly, for now, I didn't find code in neutron using slave db feature. (If I'm wrong, please let me know, thanks)

some code may use slave db to reduce the master's load, for i.e. nova periodic task[1][2], they are read operations and can accept a little lag, but operator should ensure the lag is not too high.

[0] https://github.com/openstack/oslo-incubator/blob/master/openstack/common/db/sqlalchemy/session.py (https://github.com/openstack/oslo-inc...) [1] https://github.com/openstack/nova/blob/master/nova/db/api.py (https://github.com/openstack/nova/blo...) (#631, for i.e.) [2] https://blueprints.launchpad.net/nova/+spec/periodic-tasks-to-db-slave (https://blueprints.launchpad.net/nova...)

edit flag offensive delete link more
0

answered 2014-01-08 05:05:28 -0500

I don't see any neutron function using slave. But in neutron, there's method for get_session in https://github.com/openstack/neutron/blob/master/neutron/openstack/common/db/sqlalchemy/session.py (https://github.com/openstack/neutron/...)

That's why I got confused here.

From your reference[0], other projects should get session from oslo get_session(), right? I looked at cinder,nova and neutron, all of them define and consume their own get_session function instead of oslo's. This is potential code refactor work here?

Thanks for explanation!

edit flag offensive delete link more
0

answered 2014-01-09 02:37:32 -0500

aji-zqfan gravatar image

oslo is a common code project (and it is a bit strict to sync upstream code from oslo to each project.), the link you provided in neutron is exactly oslo code. you can read https://wiki.openstack.org/wiki/Oslo for more detail.

some projects will define their own get_session, but just a simple wrapper to oslo's get_session, or maybe some special case cannot be met in specific low level driver so particular code should handle that. usually, openstack projects use oslo get_session directly, for i.e., nova, keystone, cinder, glance.

Neutron has written a simple helper function get_session, which just changes the default value of parameter sqlite_fk(which means SqliteForeignKeys) in oslo get_session, you can dig deeper to figure out why it does that, and I think this is another question.

-------------------details can be ignored--------------------- zqfan@openstack-dev:~/openstack/nova/nova$ grep -n 'def get_session' ./ -r ./openstack/common/db/sqlalchemy/session.py:412:def get_session(autocommit=True, expire_on_commit=False, ./tests/virt/xenapi/test_xenapi.py:128:def get_session(): ./virt/hyperv/basevolumeutils.py:105: def get_session_id_from_mounted_disk(self, physical_drive_path): ./virt/baremetal/db/sqlalchemy/session.py:48:def get_session(autocommit=True, expire_on_commit=False): ./virt/xenapi/client/session.py:151: def get_session_id(self):

zqfan@openstack-dev:~/openstack/cinder/cinder$ grep -n 'def get_session' ./ -r ./openstack/common/db/sqlalchemy/session.py:370:def get_session(autocommit=True, expire_on_commit=False, ./volume/drivers/xenapi/lib.py:361: def get_session(self):

zqfan@openstack-dev:~/openstack/neutron/neutron$ grep -n 'def get_session' ./ -r./openstack/common/db/sqlalchemy/session.py:414:def get_session(autocommit=True, expire_on_commit=False, ./db/api.py:46:def get_session(autocommit=True, expire_on_commit=False):

edit flag offensive delete link more
0

answered 2014-01-09 02:59:14 -0500

Thanks ZhiQiang Fan, that solved my question.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-01-07 06:13:11 -0500

Seen: 150 times

Last updated: Jan 09 '14