Skip to content

qa: Add opt-in min_size protection to OSD thrasher - #67860

Open
kamoltat wants to merge 1 commit into
ceph:mainfrom
kamoltat:wip-ksirivad-fix-thrash-osds
Open

kamoltat wants to merge 1 commit into
ceph:mainfrom
kamoltat:wip-ksirivad-fix-thrash-osds

Conversation

@kamoltat

@kamoltat kamoltat commented Mar 17, 2026 •

Copy link
Copy Markdown
Member

Problem:

The OSD thrasher randomly kills OSDs without checking if it would
violate any PG's min_size. This leads to data loss scenarios
where multiple OSDs in the same acting set are killed in quick succession,
leaving PGs with fewer replicas than min_size and resulting in unfound
objects that cannot be recovered.

Solution:
Add opt-in protection to kill_osd() that checks PG states before selecting
an OSD to kill:

1. New _get_safe_to_kill_osds() method identifies OSDs whose death would
   not violate any PG's min_size by checking acting sets against pool
   min_size values.

2. Modified kill_osd() to accept respect_min_size parameter (default False):

3. Updated test_pool_min_size() to explicitly set respect_min_size=False
   since that test intentionally violates min_size.

This provides protection against systematic min_size violations while

Signed-off-by: Kamoltat (Junior) Sirivadhna [email protected]

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@github-actions github-actions Bot added the tests label Mar 17, 2026
@kamoltat
kamoltat requested review from a team, bill-scales, ljflores and rzarzynski March 17, 2026 20:06
Comment thread qa/tasks/ceph_manager.py Outdated
@@ -1056,7 +1126,8 @@ def test_pool_min_size(self):
# further reducing redundancy. With this number of injects in
# quick succession this risks a PG in the pool becoming dead
for i in range(0, most_killable):
self.kill_osd(osd=acting_set[i])
# Explicitly disable min_size protection - this test wants to test min_size behavior
self.kill_osd(osd=acting_set[i], respect_min_size=False)

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.

I'm afraid kill_osd() might have more users like this one. Defaulting respect_min_size to True is pretty impactful.

How many callers does kill_osd() have?

@@ -29,6 +29,7 @@ overrides:
- osds down
- osd down
- OBJECT_UNFOUND
- PG_DAMAGED

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.

👍

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.

Maybe we should split this into its own PR as I think it is just this that is required to make the test pass?

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.

Yeah, looks the PG_DAMAGED doesn't require any further discussion.

Comment thread qa/tasks/ceph_manager.py
@@ -337,14 +337,84 @@ def run_ceph_bluestore_tool(self, remote, osd, cmd):
stdout=StringIO(),
stderr=StringIO())

def kill_osd(self, osd=None, mark_down=False, mark_out=False):
def _get_safe_to_kill_osds(self):

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.

👍 I really like the idea of this function, in particular I'd like to be able to run qa tests with a mixture of different EC pools with different levels of redundancy, or a mix of EC and replica pools,. Currently this doesn't work well because the thrasher selects a pool to perform an error inject and disregards the state of the PGs in the other pools when injecting errors, but then does things like waiting for active+clean or recovered which fail when a PG is dead because of too many injects.

Comment thread qa/tasks/ceph_manager.py Outdated

return list(safe_osds)

def kill_osd(self, osd=None, mark_down=False, mark_out=False, respect_min_size=True):

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.

I don't like the idea of enabling respect_min_size by default, I think it should be opt in rather than opt out. I can't decide whether this should be something that individual error injects select (e.g. within OSDThrasher) or whether this should be something that is set at the teuthology run level by a yaml setting

Comment thread qa/tasks/ceph_manager.py Outdated
osd = random.choice(safe_osds)
self.log(f'Selected OSD {osd} from {len(safe_osds)} safe candidates')
else:
# No safe OSDs - allow violation with low probability for edge case testing

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.

I don't think this is a good idea. I get what you are trying to do - causing a set of error injects that is more realistic and focuses mainly on scenarios that don't take things offline, but allow a few cases that do so we get coverage. My problem with this approach is that this isn't how the rest of the test cases are written - tests are generally very binary and expect things to go offline or they don't - they don't cope well with a random outcome. All this will do is make it slightly less likely that a test will fail

I was also confused by the naming of the respect_min_size parameter which made me think it wouldn't violate min_size and then this code that sometimes does, if we keep this then maybe the parameter should be try_respect_min_size?

Comment thread qa/tasks/ceph_manager.py Outdated
@@ -1056,7 +1126,8 @@ def test_pool_min_size(self):
# further reducing redundancy. With this number of injects in
# quick succession this risks a PG in the pool becoming dead
for i in range(0, most_killable):
self.kill_osd(osd=acting_set[i])
# Explicitly disable min_size protection - this test wants to test min_size behavior
self.kill_osd(osd=acting_set[i], respect_min_size=False)

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.

This is a bit unintuitive, this particular error inject is trying to reduce the size of a pool to min size, but not below min size - it is already querying the min size of the pool to work out how many PGs it should be able to kill. If this test is running on its own with just one pool then there should be no need to set this, if the test is running with other error injects as well then just selecting it here isn't going to help. What is the justification for setting it here?

@@ -29,6 +29,7 @@ overrides:
- osds down
- osd down
- OBJECT_UNFOUND
- PG_DAMAGED

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.

Maybe we should split this into its own PR as I think it is just this that is required to make the test pass?

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@kamoltat kamoltat changed the title qa: Add soft min_size protection to OSD thrasher & Ignore PG_DAMAGED qa: Add soft min_size protection to OSD thrasher Apr 14, 2026
Problem:
The OSD thrasher randomly kills OSDs without checking if it would
violate any PG's min_size. This leads to data loss scenarios
where multiple OSDs in the same acting set are killed in quick succession,
leaving PGs with fewer replicas than min_size and resulting in unfound
objects that cannot be recovered.

Solution:
Add opt-in protection to kill_osd() that checks PG states before selecting
an OSD to kill:

1. New _get_safe_to_kill_osds() method identifies OSDs whose death would
   not violate any PG's min_size by checking acting sets against pool
   min_size values.

2. Modified kill_osd() to accept respect_min_size parameter (default False):

3. Updated test_pool_min_size() to explicitly set respect_min_size=False
   since that test intentionally violates min_size.

This provides protection against systematic min_size violations while

Signed-off-by: Kamoltat (Junior) Sirivadhna <[email protected]>
@kamoltat
kamoltat force-pushed the wip-ksirivad-fix-thrash-osds branch from 522eb8c to 23dc84b Compare April 14, 2026 19:31
@kamoltat kamoltat changed the title qa: Add soft min_size protection to OSD thrasher qa: Add opt-in min_size protection to OSD thrasher Apr 14, 2026
@kamoltat

Copy link
Copy Markdown
Member Author

@rzarzynski @bill-scales I have separate the PRs into two where:

  1. qa: Add opt-in min_size protection to OSD thrasher #67860 (currenty PR) -> provide opt-in min_size protection to OSD thrasher
  2. qa/suites/upgrade: ignore PG_DAMAGED #68365 -> ignore PG_DAMAGED fixing https://tracker.ceph.com/issues/72424

This current PR creates the option for kill_osd to protect min_size but is not yet used anywhere yet. I'm not sure if we want to protect min_size when we roll the dice in def choose_action

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Jun 13, 2026
@kamoltat kamoltat removed the stale label Jun 17, 2026
@kamoltat

Copy link
Copy Markdown
Member Author

@rzarzynski just need a quick review. Thanks!

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Aug 16, 2026

@ljflores ljflores left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Added some thoughts. I do think this could also be helpful in resolving https://tracker.ceph.com/issues/75216.

Comment thread qa/tasks/ceph_manager.py
Comment on lines +355 to +356
for pg in pgs:
pool_id = int(pg['pgid'].split('.')[0])

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we iterate through the pools rather than the PGs? That could cut down on the run time of this loop.

Comment thread qa/tasks/ceph_manager.py
Comment on lines +377 to +383
# If this PG is at or below min_size, don't kill any of its OSDs
if len(acting) <= min_size:
for osd in acting:
if osd in safe_osds:
safe_osds.discard(osd)
self.log(f'OSD {osd} cannot be killed: PG {pg["pgid"]} '
f'has acting set {acting} at/below min_size {min_size}')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This implies that PGs might have different min_sizes, so we will just ignore the ones that are at or below min_size.

However, I think min_size is hard-coded in all the thrashers to be 2. For example: https://github.com/ceph/ceph/blob/main/qa/suites/rados/thrash/thrashers/pggrow.yaml

That means we might skip over all PGs and never thrash anything. Would it be better to dynamically adjust min_size to be whatever the largest "k" value is in the cluster?

That way, we will still have some thrashing activity going on.

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Oct 20, 2026
@kamoltat kamoltat removed the stale label Oct 27, 2026
@ljflores ljflores self-assigned this Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants