Skip to content

osd: add pg-upmap-primary to clean_pg_upmaps - #62067

Merged
NitzanMordhai merged 1 commit into
ceph:mainfrom
ljflores:wip-tracker-67179
Feb 15, 2026
Merged

NitzanMordhai merged 1 commit into
ceph:mainfrom
ljflores:wip-tracker-67179

Conversation

@ljflores

@ljflores ljflores commented Feb 28, 2025 •

Copy link
Copy Markdown
Member

osd: add pg-upmap-primary to clean_pg_upmaps

This commit adds handling of pg_upmap_primary to clean_pg_upmaps
so invalid mappings are properly removed. Invalid mappings occur
when pools are deleted, the PG size is decreased, or an OSD is
marked down/out.

Test cases cover cases where:

  1. PG num is reduced (all pg_upmap_primary mappings should be canceled)
  2. An OSD outside of the up set has been mapped as the primary
  3. An OSD is marked "out"
  4. A mapping is redundant
  5. A pool is deleted

Run the unit test with:

$ ninja unittest_osdmap
$ ./bin/unittest_osdmap --gtest_filter=*CleanPGUpmapPrimaries* --debug_osd=10

Fixes: https://tracker.ceph.com/issues/67265
Signed-off-by: Laura Flores [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

@ljflores
ljflores requested a review from a team as a code owner February 28, 2025 23:07
@ljflores

Copy link
Copy Markdown
Member Author

jenkins test api

@rzarzynski rzarzynski left a comment

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.

LGTM. Just a nit. definitely not a blocking one.

Comment thread src/osd/OSDMap.cc
ldout(cct, 10) << __func__ << " cancel invalid pg_upmap_primaries entry "
<< l->first << "->" << l->second
<< dendl;
pending_inc->old_pg_upmap_primary.insert(pg);

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.

Comment thread src/test/osd/TestOSDMap.cc Outdated
set_up_map();

// Build a CRUSH rule of type host
const int expected_host_num = 3;

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.

nit: EXPECTED_HOST_NUM.

Comment thread src/test/osd/TestOSDMap.cc Outdated
nextmap.apply_incremental(cleanup_inc);

// Ensure stale pg_upmap_primary entries are removed
ASSERT_EQ(nextmap.get_num_pg_upmap_primaries(), 8);

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!

Comment thread src/test/osd/TestOSDMap.cc Outdated
nextmap.apply_incremental(cleanup_inc);

// Ensure stale pg_upmap_primary entries are removed
ASSERT_EQ(nextmap.get_num_pg_upmap_primaries(), 8);

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 OK. The only thing is that you create illegal pg_upmap_prims (where the prim is not in the acting set of the pg, which is blocked in the code). The clean command should also remove such records.
The "normal" path would in line 1423 take the secondary and not (primary + 1) % num_osds.
In addition I would add a test that creates illegal pg_primaries on purpose (where the primary is not in the PG) and see that the clean removes them (this can be done without changing the pg_num in te test process).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed now with reworked test

@github-actions

github-actions Bot commented Jun 8, 2025

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 8, 2025
@ljflores ljflores removed the stale label Jun 10, 2025
Comment thread src/tools/osdmaptool.cc Outdated
@@ -114,6 +114,11 @@ void print_inc_upmaps(const OSDMap::Incremental& pending_inc, int fd, bool vstar
ss << prefix;
ss << cmd + " osd pg-upmap-primary " << i.first << " " << i.second << std::endl;
}
for (auto& i : pending_inc.old_pg_upmap_primary) {

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.

Should you be removing the old pg-upmap-primary entries before adding the new ones? I'm guessing a pg could be on both lists? The code above for upmap-items and pg-upmap do deletes then adds.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct, this is fixed!

@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 Sep 14, 2025
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

This commit adds handling of pg_upmap_primary to `clean_pg_upmaps`
so invalid mappings are properly removed. Invalid mappings occur
when pools are deleted, the PG size is decreased, or an OSD is
marked down/out.

Test cases cover cases where:
1. PG num is reduced (all pg_upmap_primary mappings should be canceled)
2. An OSD outside of the up set has been mapped as the primary
3. An OSD is marked "out"
4. A mapping is redundant
5. A pool is deleted

Run the unit test with:
$ ninja unittest_osdmap
$ ./bin/unittest_osdmap --gtest_filter=*CleanPGUpmapPrimaries* --debug_osd=10

Fixes: https://tracker.ceph.com/issues/67265
Signed-off-by: Laura Flores <[email protected]>
@ljflores

Copy link
Copy Markdown
Member Author

jenkins test api

Comment thread src/osd/OSDMap.cc
<< "pg_upmap_primaries entry "
<< k->first << "->" << k->second
<< dendl;
pending_inc->new_pg_upmap_primary.erase(k);

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.

My understanding: "To not add a new mapping".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes

Comment thread src/osd/OSDMap.cc
ldout(cct, 10) << __func__ << " cancel invalid pg_upmap_primaries entry "
<< l->first << "->" << l->second
<< dendl;
pending_inc->old_pg_upmap_primary.insert(pg);

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.

"Te remove if already present".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Right

Comment thread src/osd/OSDMap.cc

// Get the pool from the provided pool id
const pg_pool_t* pool = get_pg_pool(pid);
if (!pool) {

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, no pool -> do not iterate over its PGs.

@bill-scales bill-scales left a comment

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.

LGTM

@JoshSalomon JoshSalomon left a comment

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.

LGTM

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@NitzanMordhai
NitzanMordhai merged commit be99f97 into ceph:main Feb 15, 2026
@github-actions

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/22038060145

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.

6 participants