Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions doc/rados/operations/health-checks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,12 @@ which are frequently updated. This warning only appears when
the cluster is provisioned with at least three Ceph Monitors and are using the
``connectivity`` election strategy.

To reduce false alarms from transient network issues, detected netsplits are
not immediately reported as health warnings. Instead, they must persist for at
least ``mon_netsplit_grace_period`` seconds (default: 9 seconds) before being
reported. If the network partition resolves within this grace period, no health
warning is emitted.

Network partitions are reported in two ways:

- As location-level netsplits (e.g., "Netsplit detected between dc1 and dc2") when
Expand All @@ -177,6 +183,18 @@ Network partitions are reported in two ways:
The system prioritizes reporting at the highest topology level (``datacenter``, ``rack``, etc.)
when possible, to better help operators identify infrastructure-level network issues.

To adjust the grace period threshold, run the following command:

.. prompt:: bash $

ceph config set mon mon_netsplit_grace_period <seconds>

To disable the grace period entirely (immediate reporting), set the value to 0:

.. prompt:: bash $

ceph config set mon mon_netsplit_grace_period 0

AUTH_INSECURE_GLOBAL_ID_RECLAIM
_______________________________

Expand Down
1 change: 1 addition & 0 deletions qa/config/rados.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ overrides:
osd mclock profile: high_recovery_ops
mon:
mon scrub interval: 300
debug mon: 30
1 change: 1 addition & 0 deletions qa/suites/netsplit/ceph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ overrides:
- \(PG_AVAILABILITY\)
- \(SLOW_OPS\)
- \[WRN\]
- \(MON_NETSPLIT\)
tasks:
- install:
- ceph:
1 change: 1 addition & 0 deletions qa/suites/rados/monthrash/ceph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ overrides:
mon osdmap full prune txsize: 2
mon scrub inject crc mismatch: 0.01
mon scrub inject missing keys: 0.05
debug ms: 20
# thrashing monitors may make mgr have trouble w/ its keepalive
log-ignorelist:
- ScrubResult
Expand Down
1 change: 1 addition & 0 deletions qa/suites/rados/monthrash/msgr-failures/few.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ overrides:
mon client directed command retry: 5
log-ignorelist:
- \(OSD_SLOW_PING_TIME
- \(MON_NETSPLIT)
1 change: 1 addition & 0 deletions qa/suites/rados/monthrash/msgr-failures/mon-delay.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ overrides:
debug monc: 10
log-ignorelist:
- \(OSD_SLOW_PING_TIME
- \(MON_NETSPLIT)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

6 changes: 6 additions & 0 deletions qa/suites/rados/monthrash/msgr-failures/none.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
overrides:
ceph:
conf:
global:
ms inject socket failures: 0

6 changes: 6 additions & 0 deletions qa/suites/rados/multimon/ceph.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
overrides:
ceph:
conf:
mon:
debug ms: 20

1 change: 1 addition & 0 deletions qa/suites/rados/multimon/msgr-failures/few.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ overrides:
mon client directed command retry: 5
log-ignorelist:
- \(OSD_SLOW_PING_TIME
- \(MON_NETSPLIT)
1 change: 1 addition & 0 deletions qa/suites/rados/multimon/msgr-failures/many.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ overrides:
mon mgr beacon grace: 90
log-ignorelist:
- \(OSD_SLOW_PING_TIME
- \(MON_NETSPLIT)
6 changes: 6 additions & 0 deletions qa/suites/rados/multimon/msgr-failures/none.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
overrides:
ceph:
conf:
global:
ms inject socket failures: 0

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ tasks:
- \(PG_AVAILABILITY\)
- \(SLOW_OPS\)
- \[WRN\]
- \(MON_NETSPLIT\)
- workunit:
clients:
client.0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ tasks:
- \(OSD_DATACENTER_DOWN\)
- \(OSD_DOWN\)
- \(OSD_HOST_DOWN\)


- workunit:
clients:
client.0:
Expand Down
1 change: 1 addition & 0 deletions qa/suites/rados/singleton/msgr-failures/few.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ overrides:
log-ignorelist:
- \(OSD_SLOW_PING_TIME
- \(MON_DOWN\)
- \(MON_NETSPLIT\)
1 change: 1 addition & 0 deletions qa/suites/rados/singleton/msgr-failures/many.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ overrides:
log-ignorelist:
- \(OSD_SLOW_PING_TIME
- \(MON_DOWN\)
- \(MON_NETSPLIT\)
16 changes: 15 additions & 1 deletion qa/tasks/mon_thrash.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class MonitorThrasher(Thrasher):
task to run with as many as just one single monitor.
(default: True)
freeze_mon_probability: how often to freeze the mon instead of killing it,
in % (default: 0)
in % (default: 10)
freeze_mon_duration: how many seconds to freeze the mon (default: 15)
scrub Scrub after each iteration (default: True)
check_mds_failover Check if mds failover happened (default: False)
Expand Down Expand Up @@ -128,6 +128,15 @@ def __init__(self, ctx, manager, config, name, logger):
self.scrub = self.config.get('scrub', True)

self.freeze_mon_probability = float(self.config.get('freeze_mon_probability', 10))
# In some cases where many monitors froze at once and revived
# after a long time might cause the connection to take more time to establish.
# Therefore, we increase the netsplit grace period to 30 seconds.
# This is to avoid false positives in the netsplit test, while still keeping
# the integrity of the test.
if self.freeze_mon_probability > 0:
self.manager.raw_cluster_cmd(
'config', 'set', 'mon', 'mon_netsplit_grace_period', '30')

self.freeze_mon_duration = float(self.config.get('freeze_mon_duration', 15.0))

assert self.max_killable() > 0, \
Expand Down Expand Up @@ -354,11 +363,13 @@ def _do_thrash(self):

if mons_to_freeze:
for mon in mons_to_freeze:
self.log('freezing mon.{m}'.format(m=mon))
self.freeze_mon(mon)
self.log('waiting for {delay} secs to unfreeze mons'.format(
delay=self.freeze_mon_duration))
time.sleep(self.freeze_mon_duration)
for mon in mons_to_freeze:
self.log('unfreezing mon.{m}'.format(m=mon))
self.unfreeze_mon(mon)

if self.maintain_quorum:
Expand All @@ -382,15 +393,18 @@ def _do_thrash(self):
self.switch_task()

for mon in mons_to_kill:
self.log('reviving mon.{m}'.format(m=mon))
self.revive_mon(mon)
# do more freezes
if mons_to_freeze:
for mon in mons_to_freeze:
self.log('freezing mon.{m}'.format(m=mon))
self.freeze_mon(mon)
self.log('waiting for {delay} secs to unfreeze mons'.format(
delay=self.freeze_mon_duration))
time.sleep(self.freeze_mon_duration)
for mon in mons_to_freeze:
self.log('unfreezing mon.{m}'.format(m=mon))
self.unfreeze_mon(mon)

self.manager.wait_for_mon_quorum_size(len(mons))
Expand Down
24 changes: 21 additions & 3 deletions qa/tasks/stretch_mode_disable_enable.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,21 @@ def _bring_back_mon(self, mon):
"""
Bring back the mon.
"""
log.debug("_bring_back_mon %s", mon)
# If the mon is already up, do nothing
quorum_names = self.mgr_cluster.mon_manager.get_mon_quorum_names()
if mon in quorum_names:
log.debug("mon.%s is already up", mon)
return
# If the mon is not up, try to bring it back
log.debug("Bringing back mon.%s", mon)
try:
self.ctx.daemons.get_daemon('mon', mon, self.CLUSTER).restart()
except Exception:
log.error("Failed to bring back mon.{}".format(str(mon)))
pass

def _get_host(self, osd):
def _get_osd_host(self, osd):
"""
Get the host of the osd.
"""
Expand All @@ -142,7 +150,7 @@ def _move_osd_back_to_host(self, osd):
"""
Move the osd back to the host.
"""
host = self._get_host(osd)
host = self._get_osd_host(osd)
assert host is not None, "The host of osd {} is not found.".format(osd)
log.debug("Moving osd.%d back to %s", osd, host)
self.mgr_cluster.mon_manager.raw_cluster_cmd(
Expand All @@ -155,6 +163,7 @@ def tearDown(self):
Clean up the cluster after the test.
"""
# Remove the pool
log.debug("Tear down the test")
if self.POOL in self.mgr_cluster.mon_manager.pools:
self.mgr_cluster.mon_manager.remove_pool(self.POOL)

Expand All @@ -168,7 +177,14 @@ def tearDown(self):
if osd['up'] == 0:
self.mgr_cluster.mon_manager.revive_osd(osd['osd'])
self._move_osd_back_to_host(osd['osd'])


# Set the mon_netsplit_grace_period to 30 seconds.
# Sometimes when many mons restart at the same time
# it can take longer for the monitors to establish
# a connection.
self.mgr_cluster.mon_manager.raw_cluster_cmd(
'config', 'set', 'mon', 'mon_netsplit_grace_period', '30'
)
# Bring back all the mons
mons = self._get_all_mons_from_all_dc()
for mon in mons:
Expand Down Expand Up @@ -359,6 +375,7 @@ def _stretch_mode_enabled_correctly(self):
self.TIEBREAKER_MON_NAME,
monmap['tiebreaker_mon']
)
log.debug("Stretch mode is enabled correctly.")

def _stretch_mode_disabled_correctly(self):
"""
Expand Down Expand Up @@ -445,6 +462,7 @@ def _stretch_mode_disabled_correctly(self):
"",
monmap['tiebreaker_mon']
)
log.debug("Stretch mode is disabled correctly.")

def test_disable_stretch_mode(self):
"""
Expand Down
70 changes: 70 additions & 0 deletions qa/tasks/test_netsplit.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,50 @@ def _check_if_connect(self, config):
except Exception:
return False

def _check_mon_netsplit_warning(self):
"""
Returns True if MON_NETSPLIT warning exists in health checks.
"""
(client,) = self.ctx.cluster.only(self.CLIENT).remotes.keys()
arg = ['ceph', 'health', 'detail', '--format=json']
proc = client.run(args=arg, wait=True, stdout=StringIO(), timeout=30)
if proc.exitstatus != 0:
log.error("ceph health detail failed")
raise Exception("ceph health detail failed")
out = proc.stdout.getvalue()
j = json.loads(out)
checks = j.get("checks", {})
return "MON_NETSPLIT" in checks

def _check_mon_netsplit_warning_raised(self, detail):
"""
Check if the MON_NETSPLIT warning with the given detail is raised.
"""
log.info("Checking if MON_NETSPLIT warning is raised with detail: {}".format(detail))
(client,) = self.ctx.cluster.only(self.CLIENT).remotes.keys()
arg = ['ceph', 'health', 'detail', '--format=json']
proc = client.run(args=arg, wait=True, stdout=StringIO(), timeout=30)
if proc.exitstatus != 0:
log.error("ceph health detail failed")
raise Exception("ceph health detail failed")
out = proc.stdout.getvalue()
j = json.loads(out)
# Access health checks
checks = j.get("checks", {})
netsplit = checks.get("MON_NETSPLIT", {})
if not netsplit:
log.info("MON_NETSPLIT not found in health checks")
return False

# Check if the expected detail is present
for d in netsplit.get("detail", []):
if detail in d.get("message", ""):
log.info("Found MON_NETSPLIT warning with detail: {}".format(d))
return True

log.info("MON_NETSPLIT found but detail does not match")
return False

def test_netsplit_dc1_dc2(self):
"""
Test Netsplit between dc1 and dc2
Expand Down Expand Up @@ -220,6 +264,13 @@ def test_netsplit_dc1_dc2(self):
lambda: self._check_if_disconnect(config),
timeout=self.RECOVERY_PERIOD,
)
# check if the MON_NETSPLIT warning is raised we expect none
# because this is stretch mode
self.wait_until_true_and_hold(
lambda: not self._check_mon_netsplit_warning(),
timeout=self.RECOVERY_PERIOD,
success_hold_time=self.SUCCESS_HOLD_TIME
)
# check the cluster is accessible
self.wait_until_true_and_hold(
lambda: self._reply_to_mon_command(),
Expand Down Expand Up @@ -263,6 +314,12 @@ def test_netsplit_dc1_dc2(self):
lambda: self._check_if_connect(config),
timeout=self.RECOVERY_PERIOD,
)
# check if no MON_NETSPLIT warning is raised
self.wait_until_true_and_hold(
lambda: not self._check_mon_netsplit_warning(),
timeout=self.RECOVERY_PERIOD,
success_hold_time=self.SUCCESS_HOLD_TIME
)
# check if all the PGs are active+clean
self.wait_until_true_and_hold(
lambda: self._pg_all_active_clean(),
Expand Down Expand Up @@ -305,6 +362,13 @@ def test_netsplit_arbiter_dc1_and_dc1_dc2(self):
lambda: self._check_if_disconnect(dc1_dc2),
timeout=self.RECOVERY_PERIOD,
)
# check if the MON_NETSPLIT warning is raised we expect none
# because this is stretch mode
self.wait_until_true_and_hold(
lambda: not self._check_mon_netsplit_warning(),
timeout=self.RECOVERY_PERIOD,
success_hold_time=self.SUCCESS_HOLD_TIME
)
# check the cluster is accessible
self.wait_until_true_and_hold(
lambda: self._reply_to_mon_command(),
Expand Down Expand Up @@ -352,6 +416,12 @@ def test_netsplit_arbiter_dc1_and_dc1_dc2(self):
lambda: self._check_if_connect(dc1_dc2),
timeout=self.RECOVERY_PERIOD,
)
# check if the MON_NETSPLIT warning is not raised
self.wait_until_true_and_hold(
lambda: not self._check_mon_netsplit_warning(),
timeout=self.RECOVERY_PERIOD,
success_hold_time=self.SUCCESS_HOLD_TIME
)
# check if all the PGs are active+clean
self.wait_until_true_and_hold(
lambda: self._pg_all_active_clean(),
Expand Down
Loading