Add a CLI command for listing namespace locations counts #1775
The condition only calls ns_location_list when namespaces is non-empty. When show_ns_locations is True but the namespace list is empty, the function falls through to the regular namespace listing logic and displays "No namespaces in..." messages. This creates inconsistent behavior. Consider removing the namespaces_info.namespaces check to always call ns_location_list when show_ns_locations is True, allowing that function to handle the empty case consistently.
if show_ns_locations:
The load balancing group is set to 0 if it's falsy at line 2664, which means the condition if lb at line 2683 will always be True (since lb is either the original non-zero value or 0). This makes the else branch with "<n/a>" unreachable. Consider either removing the default assignment at line 2664 and keeping the check at 2683, or removing the conditional at 2683 and always converting to string since 0 is a valid load balancing group value.
Pull request overview
This pull request adds a new CLI command namespace list_locations that displays the distribution of namespaces by site location, grouped by subsystem and load balancing group. This addresses issue #1763 by providing administrators with visibility into how namespaces are distributed across different geographic locations.
Changes:
ns_location_list() function to aggregate and display namespace counts per locationns_list() function to support a show_ns_locations parameter for routing to location list viewReviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
| ---- | ----------- |
| control/cli.py | Added new ns_location_list() function, modified ns_list() to support location listing mode, added CLI action definition for list_locations, and updated location display to use "<default>" instead of "<N/A>" |
| tests/test_cli_list_ns_locations.py | Added comprehensive test coverage with two-gateway setup testing location distribution across subsystems and load balancing groups |
| .github/workflows/build-container.yml | Added new test to CI/CD pipeline test matrix |
---
💡 <a href="/ceph/ceph-nvmeof/new/devel/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
changed
This is wrong. When lb is 0 we'll get the "<n/a>" string.
Several of these assert lines are likely to exceed the repo’s flake8 max-line-length = 100 limit (E501), which will fail make verify. Consider factoring the regex into a local variable, or splitting the pattern string across multiple shorter concatenated literals to keep each physical line <= 100 chars.
These assertions appear to have very long lines (especially the regex patterns) and may violate the project’s flake8 100-character line limit. Please wrap/split these into shorter physical lines to avoid E501 failures in CI.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
---
💡 <a href="/ceph/ceph-nvmeof/new/devel/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
This is OK. All the lines are shorter than 100 characters
All the lines are shorter than 100 characters.
it can happen ?
It shouldn't happen unless there is some bug in the gateway. I just prefer to write the code so it wouldn't crash even if there is a bug elsewhere.
I just abort with an error message in such a case as this means we have a bug somewhere.
Approved these changes.
leonidc
gbregman
Fixes: #1763