← Back to Pull requests

rebalance handles degraded namespaces #1961

Merged
leonidc merged 2 files (123 lines) on Jun 25, 2026 05:12 UTC
View on GitHub
leonidc leonidc commented on Jun 24, 2026 04:37 UTC
Author

No description provided by author.

Diff: 123 lines (+95 / -28) across 2 files Reviewer: gbregman Review duration: 1475m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.33) × (1 − Review Confidence (0.87)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.33 · 123 lines diff across 2 files
0.33
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.90 · 5 substantive comment(s)
0.90
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
87%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.288
Empty Description empty_description
0.060
Real PR Conversation Timeline
10 items
gbregman gbregman commented on code on Jun 24, 2026 11:34 UTC
Code Review
control/grpc.py:1
@@ -3802,17 +3816,23 @@ def namespace_change_load_balancing_group_safe(self, request, context):
             errmsg = f"{change_lb_group_failure_prefix}: Namespace not found"
             self.logger.error(errmsg)
             return pb2.req_status(status=errno.ENODEV, error_message=errmsg)
-        anagrpid = find_ret.anagrpid
+        anagrpid = abs(find_ret.anagrpid)
 
         # below checks are legal only if command is initiated by local cli or is sent from
         # the local rebalance logic.
         if context:
-            grps_list = self.ceph_utils.get_number_created_gateways(
-                self.gateway_pool, self.gateway_group, False)
-            if request.anagrpid not in grps_list:
-                self.logger.debug(f"Load balancing groups: {grps_list}")
-                errmsg = f"{change_lb_group_failure_prefix}: Load balancing group " \
-                         f"{request.anagrpid} doesn't exist"
+            if not maintenance:
+                grps_list = self.ceph_utils.get_number_created_gateways(
+                    self.gateway_pool, self.gateway_group, False)
+                if request.anagrpid not in grps_list:
+                    self.logger.debug(f"Load balancing groups: {grps_list}")
+                    errmsg = f"{change_lb_group_failure_prefix}: Load balancing group " \
+                             f"{request.anagrpid} doesn't exist"
+                    self.logger.error(errmsg)
+                    return pb2.req_status(status=errno.ENODEV, error_message=errmsg)
+            elif request.anagrpid != GatewayService.MAINTENANCE_ANA_GROUP:
+                errmsg = f"{change_lb_group_failure_prefix}: Wrong Load balancing group " \
+                         f"{request.anagrp} in Maintenance mode"
                 self.logger.error(errmsg)

Not a big deal, but in this case it's better to return EINVAL and not ENODEV.

gbregman gbregman commented on code on Jun 24, 2026 11:36 UTC
Code Review
control/rebalance.py:1
@@ -28,6 +28,7 @@ def __init__(self, gateway_service):
             "gateway",
             "rebalance_period_sec",
             7)
+        self.degraded_group = gateway_service.MAINTENANCE_ANA_GROUP

Not a big deal, but better use GatewayService.MAINTENANCE_ANA_GROUP this is defined per class and not per specific instance.

gbregman gbregman commented on code on Jun 24, 2026 11:39 UTC
Code Review
control/rebalance.py:1
@@ -310,6 +314,36 @@ def rebalance_logic(self, request, context) -> int:
             return 0
         return 1
 
+    def periodic_scan_degraded_ns(self, context, ana_id) -> int:
+        # 1. check ns in ana maintenance group
+        ns = self.gw_srv.subsystem_nsid_bdev_and_uuid.get_all_namespaces_by_ana_group_id(
+            self.degraded_group
+        )
+        self.logger.debug(f"Doing loop on namespaces in anagrp {self.degraded_group} ")
+        for nsid, subsys in ns:
+            ns_info = self.gw_srv.subsystem_nsid_bdev_and_uuid.find_namespace(subsys, nsid)
+            self.logger.info(f"Found nsid {nsid} nqn {subsys} in degraded anagrp"

You should use "anagrp" in an info message as it is visible to users. It should be "load balancing group" or something similar.

gbregman gbregman approved these changes on Jun 24, 2026 11:40 UTC
Approved Reviewer

A few minor comments

leonidc leonidc commented on code on Jun 24, 2026 15:12 UTC
Code Review
control/rebalance.py:1
@@ -28,6 +28,7 @@ def __init__(self, gateway_service):
             "gateway",
             "rebalance_period_sec",
             7)
+        self.degraded_group = gateway_service.MAINTENANCE_ANA_GROUP

@gbregman ,
class Rebalance:
def __init__(self, gateway_service):
self.logger = gateway_service.logger
self.gw_srv = gateway_service
self.ceph_utils = gateway_service.ceph_utils
self.ana_grp_location = {} # fill location of each ana grp for responses of monitor
self.rebalance_period_sec = gateway_service.config.getint_with_default(
"gateway",
"rebalance_period_sec",
7)
self.degraded_group = gateway_service.MAINTENANCE_ANA_GROUP <== it is the same constant
rebalance gets this gatewayservice as a parameter
I tried to import .grpc but there is a cyclic dependeny

leonidc leonidc commented on code on Jun 24, 2026 15:13 UTC
Code Review
control/rebalance.py:1
@@ -310,6 +314,36 @@ def rebalance_logic(self, request, context) -> int:
             return 0
         return 1
 
+    def periodic_scan_degraded_ns(self, context, ana_id) -> int:
+        # 1. check ns in ana maintenance group
+        ns = self.gw_srv.subsystem_nsid_bdev_and_uuid.get_all_namespaces_by_ana_group_id(
+            self.degraded_group
+        )
+        self.logger.debug(f"Doing loop on namespaces in anagrp {self.degraded_group} ")
+        for nsid, subsys in ns:
+            ns_info = self.gw_srv.subsystem_nsid_bdev_and_uuid.find_namespace(subsys, nsid)
+            self.logger.info(f"Found nsid {nsid} nqn {subsys} in degraded anagrp"

@gbregman , ok , but currently rebalance uses anagrp for the load balancing group, I can change this is separate commit

leonidc leonidc commented on code on Jun 24, 2026 15:15 UTC
Code Review
control/grpc.py:1
@@ -3802,17 +3816,23 @@ def namespace_change_load_balancing_group_safe(self, request, context):
             errmsg = f"{change_lb_group_failure_prefix}: Namespace not found"
             self.logger.error(errmsg)
             return pb2.req_status(status=errno.ENODEV, error_message=errmsg)
-        anagrpid = find_ret.anagrpid
+        anagrpid = abs(find_ret.anagrpid)
 
         # below checks are legal only if command is initiated by local cli or is sent from
         # the local rebalance logic.
         if context:
-            grps_list = self.ceph_utils.get_number_created_gateways(
-                self.gateway_pool, self.gateway_group, False)
-            if request.anagrpid not in grps_list:
-                self.logger.debug(f"Load balancing groups: {grps_list}")
-                errmsg = f"{change_lb_group_failure_prefix}: Load balancing group " \
-                         f"{request.anagrpid} doesn't exist"
+            if not maintenance:
+                grps_list = self.ceph_utils.get_number_created_gateways(
+                    self.gateway_pool, self.gateway_group, False)
+                if request.anagrpid not in grps_list:
+                    self.logger.debug(f"Load balancing groups: {grps_list}")
+                    errmsg = f"{change_lb_group_failure_prefix}: Load balancing group " \
+                             f"{request.anagrpid} doesn't exist"
+                    self.logger.error(errmsg)
+                    return pb2.req_status(status=errno.ENODEV, error_message=errmsg)
+            elif request.anagrpid != GatewayService.MAINTENANCE_ANA_GROUP:
+                errmsg = f"{change_lb_group_failure_prefix}: Wrong Load balancing group " \
+                         f"{request.anagrp} in Maintenance mode"
                 self.logger.error(errmsg)

@gbregman , thanks , will do

gbregman gbregman commented on code on Jun 24, 2026 16:21 UTC
Code Review
control/rebalance.py:1
@@ -310,6 +314,36 @@ def rebalance_logic(self, request, context) -> int:
             return 0
         return 1
 
+    def periodic_scan_degraded_ns(self, context, ana_id) -> int:
+        # 1. check ns in ana maintenance group
+        ns = self.gw_srv.subsystem_nsid_bdev_and_uuid.get_all_namespaces_by_ana_group_id(
+            self.degraded_group
+        )
+        self.logger.debug(f"Doing loop on namespaces in anagrp {self.degraded_group} ")
+        for nsid, subsys in ns:
+            ns_info = self.gw_srv.subsystem_nsid_bdev_and_uuid.find_namespace(subsys, nsid)
+            self.logger.info(f"Found nsid {nsid} nqn {subsys} in degraded anagrp"

You can use whatever you want internally but you shouldn't display it to the user. Better ask Aviv which is the proper term to use in "info" messages.

gbregman gbregman commented on code on Jun 24, 2026 16:23 UTC
Code Review
control/rebalance.py:1
@@ -28,6 +28,7 @@ def __init__(self, gateway_service):
             "gateway",
             "rebalance_period_sec",
             7)
+        self.degraded_group = gateway_service.MAINTENANCE_ANA_GROUP

This is why I moved some constants to GatewayUtils. But it's not that important.

Reviewers
Assignees
leonidc leonidc
Labels
risk: low confidence: 87.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 33.3% (LOW) · Higher = larger blast radius
33.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 87.1% · Lower = rushed or shallow review
87.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4.3% · Safe to merge
4.3%