Skip to content

nvmeofgw: stretched cluster fix relocate - #69490

Merged
leonidc merged 1 commit into
ceph:mainfrom
leonidc:fix_relocation_stretched
Jul 19, 2026
Merged

leonidc merged 1 commit into
ceph:mainfrom
leonidc:fix_relocation_stretched

Conversation

@leonidc

@leonidc leonidc commented Jun 15, 2026 •

Copy link
Copy Markdown
Contributor

Fix ANA relocation procedure - need to perform relocation not only when disaster location is in cleanup state
but also when location is healthy.

https://tracker.ceph.com/issues/77803

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.

@leonidc
leonidc requested a review from a team as a code owner June 15, 2026 18:55
@leonidc
leonidc requested a review from bill-scales June 15, 2026 18:57

@baum baum 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.

The fix is sound, however before merge maybe worth fixing clear reloc_list per location iteration, see comment above

Comment thread src/mon/NVMeofGwMap.cc
if (state.location == location) {
num_gw_in_location ++;
if (state.availability != gw_availability_t::GW_AVAILABLE) {
reloc_list.push_back(state.ana_grp_id);

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.

reloc_list is declared once outside the location loop but filled inside it without clearing.
If more than one location is processed in a tick (before the new early return), later locations inherit ANA groups from earlier ones and may relocate incorrectly.

Should we reloc_list.clear() at the start of each location iteration (or declare it inside the loop)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@baum , thanks will fix
but now with early return it should work because relocate list is per location and I return after first non empty list processed

@leonidc
leonidc force-pushed the fix_relocation_stretched branch from f3b6841 to 41396ac Compare June 25, 2026 05:32

@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.

Basically LGTM with some nits.

Comment thread src/mon/NVMeofGwMap.cc
@@ -818,7 +817,9 @@ void NVMeofGwMap::handle_abandoned_ana_groups(bool& propose)

void NVMeofGwMap::check_relocate_ana_groups(const NvmeGroupKey& group_key,

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.

The commit title / PR description uses the word "fix'. However, there is no reference (the Fixes: tag) to the bug tracker. Do you want to backport the commit? If yes, then the ticket is a must-have.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rzarzynski , thanks done

Comment thread src/mon/NVMeofGwMap.cc Outdated
for (auto& state_it: state.sm_state) {
if (state_it.second == gw_states_per_group_t::GW_ACTIVE_STATE) {
num_active_ana_in_location ++;
for (auto& gw_state : gws_states) // build locations set

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: bracing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rzarzynski , thanks

Comment thread src/mon/NVMeofGwMap.cc
if (state_it.second == gw_states_per_group_t::GW_ACTIVE_STATE) {
num_active_ana_in_location ++;
for (auto& gw_state : gws_states) // build locations set
locations_set.insert(gw_state.second.location);

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 understand this step as "location dedup" as:

using NvmeGwMonStates = std::map<NvmeGwId, NvmeGwMonState>;

location there is just std::string.

Comment thread src/mon/NVMeofGwMap.cc
if ((disaster && cleanup_in_process) || (!disaster)) {
uint32_t num_gw_in_location = 0;
uint32_t num_active_ana_in_location = 0;
for (auto& gw_state : gws_states) { // loop for GWs inside group-key

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 nested looping theoretically increases the complexity (first we go through location from gws_states, then for every extracted location, we do reverse lookup) and seems suboptimal.

I assume the expected number of gateways (and thus gws_states) is small and there is no business in (over)optimizing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rzarzynski, This is a background activity called in a tick(), currently we support only 8 GWs in pool group, 3 locations may be set

Comment thread src/mon/NVMeofGwMap.cc Outdated
for (auto& gw_state : gws_states) { // loop for GWs inside group-key
NvmeGwMonState& state = gw_state.second;
if (state.location == location) {
num_gw_in_location ++;

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:

Suggested change
num_gw_in_location ++;
num_gw_in_location++;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rzarzynski , thanks

Comment thread src/mon/NVMeofGwMap.cc
auto& gws_states = created_gws[group_key];
gws_states[failover_gw_id].sm_state[grpid] =
gw_states_per_group_t::GW_WAIT_FAILBACK_PREPARED;
start_timer(failover_gw_id, group_key, grpid, 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: I know it's not a new code but what does 3 mean here (magic number)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@rzarzynski , thanks it should be fixed , it is a value of failback preparation timer

Comment thread src/mon/NVMeofGwMap.cc
@@ -1362,6 +1359,21 @@ void NVMeofGwMap::fsm_handle_gw_delete(
}
}

void NVMeofGwMap::fsm_handle_failback_and_relocation(

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 like it dedups the code; next time please differentiate code shuffling from other changes (makes reviews easier).

@leonidc
leonidc force-pushed the fix_relocation_stretched branch from 41396ac to 4770952 Compare June 30, 2026 07:06

@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.

Couple of minor comments, but change looks ok

Comment thread src/mon/NVMeofGwMap.cc Outdated
<< " relocate to " << location << dendl;
relocate_ana_grp(gw_state.first, group_key, anagrp,
location, propose);
return; // allow just 1 relocation during a tick()

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.

There are scenarios where relocate_ana_grp can return without doing a relocation (propose will remain set to false). Are these just transition states that will be resolved by a later tick, or are there scenarios where one ana grp is unable to relocate and could block other gw;s from relocating?

Comment thread src/mon/NVMeofGwMap.cc Outdated

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: Not new code, but this logic can only result in min_num_ana_groups_in_gw being set to MAX_NUM_ANA_GROUPS_FOR_RELOCATE or 1. Other values are not possible. If this is intended behavior then you could use a boolean instead.

@caroav caroav added the needs-qa label Jul 5, 2026
@amathuria

Copy link
Copy Markdown
Contributor

@leonidc
leonidc merged commit f72cb69 into ceph:main Jul 19, 2026
9 checks passed
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.

8 participants