mirror of
https://github.com/ceph/ceph
synced 2025-02-19 08:57:27 +00:00
ceph-volume lvm.create rollback osd creation when prepare or activate fails
Signed-off-by: Alfredo Deza <adeza@redhat.com>
This commit is contained in:
parent
6781d6498e
commit
07be6fe0ab
@ -1,11 +1,14 @@
|
||||
from __future__ import print_function
|
||||
from textwrap import dedent
|
||||
import logging
|
||||
from ceph_volume.util import system
|
||||
from ceph_volume import decorators
|
||||
from .common import create_parser
|
||||
from .common import create_parser, rollback_osd
|
||||
from .prepare import Prepare
|
||||
from .activate import Activate
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Create(object):
|
||||
|
||||
@ -18,8 +21,19 @@ class Create(object):
|
||||
def create(self, args):
|
||||
if not args.osd_fsid:
|
||||
args.osd_fsid = system.generate_uuid()
|
||||
Prepare([]).prepare(args)
|
||||
Activate([]).activate(args)
|
||||
prepare_step = Prepare([])
|
||||
prepare_step.safe_prepare(args)
|
||||
osd_id = prepare_step.osd_id
|
||||
try:
|
||||
# we try this for activate only when 'creating' an OSD, because a rollback should not
|
||||
# happen when doing normal activation. For example when starting an OSD, systemd will call
|
||||
# activate, which would never need to be rolled back.
|
||||
Activate([]).activate(args)
|
||||
except Exception:
|
||||
logger.error('lvm activate was unable to complete, while creating the OSD')
|
||||
logger.info('will rollback OSD ID creation')
|
||||
rollback_osd(args, osd_id)
|
||||
raise
|
||||
|
||||
def main(self):
|
||||
sub_command_help = dedent("""
|
||||
|
Loading…
Reference in New Issue
Block a user