New fix for rbd connector to work with ceph octopus
Found while testing cinder-backup with ceph on Ubuntu Focal, which installs ceph Octopus. Octopus apparently enforces the requirement that the config file contain a '[global]' section for general requirements. The '[global]' section goes back at least to ceph Hammer [0], so we will simply add it to the temporary ceph config file that os-brick generates in the RBDConnector class. [0] https://docs.ceph.com/docs/hammer/rados/configuration/mon-config-ref/ Co-authored-by: Alex Kavanagh <alex@ajkavanagh.co.uk> Co-authored-by: Ivan Kolodyazhny <e0ne@e0ne.info> Change-Id: I86eb31535d990291945de5d9846b1a03157ec2cf Closes-bug: #1865754 (cherry picked from commitc6ad4d864c
) (cherry picked from commit474583b4f8
)
This commit is contained in:
parent
d3ee7a076b
commit
91c73a433a
|
@ -97,7 +97,12 @@ class RBDConnector(base.BaseLinuxConnector):
|
||||||
try:
|
try:
|
||||||
fd, ceph_conf_path = tempfile.mkstemp(prefix="brickrbd_")
|
fd, ceph_conf_path = tempfile.mkstemp(prefix="brickrbd_")
|
||||||
with os.fdopen(fd, 'w') as conf_file:
|
with os.fdopen(fd, 'w') as conf_file:
|
||||||
conf_file.writelines([mon_hosts, "\n", keyring, "\n"])
|
# Bug #1865754 - '[global]' has been the appropriate
|
||||||
|
# place for this stuff since at least Hammer, but in
|
||||||
|
# Octopus (15.2.0+), Ceph began enforcing this.
|
||||||
|
conf_file.writelines(["[global]", "\n",
|
||||||
|
mon_hosts, "\n",
|
||||||
|
keyring, "\n"])
|
||||||
return ceph_conf_path
|
return ceph_conf_path
|
||||||
except IOError:
|
except IOError:
|
||||||
msg = (_("Failed to write data to %s.") % (ceph_conf_path))
|
msg = (_("Failed to write data to %s.") % (ceph_conf_path))
|
||||||
|
|
|
@ -171,6 +171,10 @@ class RBDConnectorTestCase(test_connector.ConnectorTestCase):
|
||||||
self.keyring)
|
self.keyring)
|
||||||
self.assertEqual(conf_path, tmpfile)
|
self.assertEqual(conf_path, tmpfile)
|
||||||
mock_mkstemp.assert_called_once_with(prefix='brickrbd_')
|
mock_mkstemp.assert_called_once_with(prefix='brickrbd_')
|
||||||
|
# Bug #1865754 - make sure generated config file has a '[global]'
|
||||||
|
# section
|
||||||
|
_, args, _ = mockopen().writelines.mock_calls[0]
|
||||||
|
self.assertIn('[global]', args[0])
|
||||||
|
|
||||||
@mock.patch.object(priv_rootwrap, 'execute', return_value=None)
|
@mock.patch.object(priv_rootwrap, 'execute', return_value=None)
|
||||||
def test_connect_local_volume(self, mock_execute):
|
def test_connect_local_volume(self, mock_execute):
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
`Bug #1865754 <https://bugs.launchpad.net/cinder/+bug/1865754>`_:
|
||||||
|
the ``RBDConnector`` class generates a temporary configuration file
|
||||||
|
to connect to Ceph. Previously, os-brick did not include a
|
||||||
|
``[global]`` section to contain the options it sets, but with the
|
||||||
|
Octopus release (15.2.0+), Ceph has begun enforcing the presence
|
||||||
|
of this section marker, which dates back at least to the Hammer
|
||||||
|
release of Ceph. With this release, os-brick includes the
|
||||||
|
``[global]`` section in the generated configuration file, which
|
||||||
|
should be backward-compatible at least to Ceph Hammer.
|
Loading…
Reference in New Issue