Skip to content

Commit

Permalink
Merge pull request #11619 from dachary/wip-17662-ceph-disk
Browse files Browse the repository at this point in the history
ceph-disk: allow using a regular file as a journal

Reviewed-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Oct 26, 2016
2 parents 2850f1d + db917d5 commit ed9b0d3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
29 changes: 29 additions & 0 deletions qa/workunits/ceph-disk/ceph-disk-test.py
Expand Up @@ -570,6 +570,35 @@ def test_activate_with_journal_dev_is_symlink(self):
os.unlink(symlink)
os.rmdir(tempdir)

def test_activate_journal_file(self):
c = CephDisk()
disks = c.unused_disks()
data_disk = disks[0]
#
# /var/lib/ceph/osd is required otherwise it may violate
# restrictions enforced by systemd regarding the directories
# which ceph-osd is allowed to read/write
#
tempdir = tempfile.mkdtemp(dir='/var/lib/ceph/osd')
c.sh("chown ceph:ceph " + tempdir + " || true")
journal_file = os.path.join(tempdir, 'journal')
osd_uuid = str(uuid.uuid1())
c.sh("ceph-disk --verbose prepare --osd-uuid " + osd_uuid +
" " + data_disk + " " + journal_file)
c.wait_for_osd_up(osd_uuid)
device = json.loads(
c.sh("ceph-disk list --format json " + data_disk))[0]
assert len(device['partitions']) == 1
partition = device['partitions'][0]
assert journal_file == os.readlink(
os.path.join(partition['mount'], 'journal'))
c.check_osd_status(osd_uuid)
c.helper("pool_read_write 1") # 1 == pool size
c.destroy_osd(osd_uuid)
c.sh("ceph-disk --verbose zap " + data_disk)
os.unlink(journal_file)
os.rmdir(tempdir)

def test_activate_separated_journal(self):
c = CephDisk()
disks = c.unused_disks()
Expand Down
8 changes: 5 additions & 3 deletions src/ceph-disk/ceph_disk/main.py
Expand Up @@ -1927,6 +1927,7 @@ def set_type(self):
raise Error('%s is not a block device' % name.capitalize,
getattr(args, name))
self.type = self.FILE
return

raise Error('%s %s is neither a block device nor regular file' %
(name.capitalize, getattr(args, name)))
Expand Down Expand Up @@ -1987,13 +1988,13 @@ def populate_data_path_file(self, path):
if getattr(self.args, space_uuid) is not None:
write_one_line(path, space_uuid,
getattr(self.args, space_uuid))

def populate_data_path_device(self, path):
self.populate_data_path_file(path)
if self.space_symlink is not None:
adjust_symlink(self.space_symlink,
os.path.join(path, self.name))

def populate_data_path_device(self, path):
self.populate_data_path_file(path)

if self.space_dmcrypt is not None:
adjust_symlink(self.space_dmcrypt,
os.path.join(path, self.name + '_dmcrypt'))
Expand Down Expand Up @@ -2022,6 +2023,7 @@ def prepare_file(self):
space_filename)
space_file = open(space_filename, 'wb')
space_file.close()
path_set_context(space_filename)

LOG.debug('%s is file %s',
self.name.capitalize(),
Expand Down

0 comments on commit ed9b0d3

Please sign in to comment.