2019-12-09 15:17:23 +00:00
|
|
|
# FIXME: this file has many undefined vars which are accessed!
|
|
|
|
# flake8: noqa
|
2014-02-24 16:00:37 +00:00
|
|
|
import logging
|
|
|
|
import contextlib
|
|
|
|
import time
|
2020-03-24 08:33:22 +00:00
|
|
|
from tasks import ceph_manager
|
2014-02-24 16:00:37 +00:00
|
|
|
from teuthology import misc
|
2021-06-15 12:55:22 +00:00
|
|
|
from teuthology.exceptions import CommandFailedError
|
|
|
|
from teuthology.orchestra.run import Raw
|
2014-02-24 16:00:37 +00:00
|
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
@contextlib.contextmanager
|
|
|
|
def task(ctx, config):
|
|
|
|
"""
|
|
|
|
Go through filesystem creation with a synthetic failure in an MDS
|
|
|
|
in its 'up:creating' state, to exercise the retry behaviour.
|
|
|
|
"""
|
|
|
|
# Grab handles to the teuthology objects of interest
|
|
|
|
mdslist = list(misc.all_roles_of_type(ctx.cluster, 'mds'))
|
|
|
|
if len(mdslist) != 1:
|
|
|
|
# Require exactly one MDS, the code path for creation failure when
|
|
|
|
# a standby is available is different
|
|
|
|
raise RuntimeError("This task requires exactly one MDS")
|
|
|
|
|
|
|
|
mds_id = mdslist[0]
|
2019-10-11 15:57:47 +00:00
|
|
|
(mds_remote,) = ctx.cluster.only('mds.{_id}'.format(_id=mds_id)).remotes.keys()
|
2014-02-24 16:00:37 +00:00
|
|
|
manager = ceph_manager.CephManager(
|
|
|
|
mds_remote, ctx=ctx, logger=log.getChild('ceph_manager'),
|
|
|
|
)
|
|
|
|
|
2014-06-06 10:08:08 +00:00
|
|
|
# Stop MDS
|
2017-10-02 00:07:05 +00:00
|
|
|
self.fs.set_max_mds(0)
|
|
|
|
self.fs.mds_stop(mds_id)
|
|
|
|
self.fs.mds_fail(mds_id)
|
2014-06-06 10:08:08 +00:00
|
|
|
|
|
|
|
# Reset the filesystem so that next start will go into CREATING
|
|
|
|
manager.raw_cluster_cmd('fs', 'rm', "default", "--yes-i-really-mean-it")
|
|
|
|
manager.raw_cluster_cmd('fs', 'new', "default", "metadata", "data")
|
2014-02-24 16:00:37 +00:00
|
|
|
|
|
|
|
# Start the MDS with mds_kill_create_at set, it will crash during creation
|
|
|
|
mds.restart_with_args(["--mds_kill_create_at=1"])
|
|
|
|
try:
|
|
|
|
mds.wait_for_exit()
|
|
|
|
except CommandFailedError as e:
|
|
|
|
if e.exitstatus == 1:
|
|
|
|
log.info("MDS creation killed as expected")
|
|
|
|
else:
|
|
|
|
log.error("Unexpected status code %s" % e.exitstatus)
|
|
|
|
raise
|
|
|
|
|
|
|
|
# Since I have intentionally caused a crash, I will clean up the resulting core
|
|
|
|
# file to avoid task.internal.coredump seeing it as a failure.
|
|
|
|
log.info("Removing core file from synthetic MDS failure")
|
|
|
|
mds_remote.run(args=['rm', '-f', Raw("{archive}/coredump/*.core".format(archive=misc.get_archive_dir(ctx)))])
|
|
|
|
|
|
|
|
# It should have left the MDS map state still in CREATING
|
2017-10-24 18:32:43 +00:00
|
|
|
status = self.fs.status().get_mds(mds_id)
|
2014-02-24 16:00:37 +00:00
|
|
|
assert status['state'] == 'up:creating'
|
|
|
|
|
|
|
|
# Start the MDS again without the kill flag set, it should proceed with creation successfully
|
|
|
|
mds.restart()
|
|
|
|
|
|
|
|
# Wait for state ACTIVE
|
2017-10-24 18:32:43 +00:00
|
|
|
self.fs.wait_for_state("up:active", timeout=120, mds_id=mds_id)
|
2014-02-24 16:00:37 +00:00
|
|
|
|
|
|
|
# The system should be back up in a happy healthy state, go ahead and run any further tasks
|
|
|
|
# inside this context.
|
|
|
|
yield
|