chihsuan commented on code in PR #10714:
URL: https://github.com/apache/ozone/pull/10714#discussion_r3571242671


##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/capacity/capacity.tsx:
##########
@@ -202,18 +202,27 @@ const Capacity: React.FC<object> = () => {
     }
   };
 
-  // Adjust the polling interval based on DN scan status:
+  // Keep the latest refresh callback in a ref so the interval below always 
calls
+  // the current closure instead of a stale one captured when the effect last 
ran.
+  const loadDataIfIdleRef = React.useRef(loadDataIfIdle);
+  loadDataIfIdleRef.current = loadDataIfIdle;
+
+  // Drive the DN pending-deletion scan through to completion:
   // fast (5s) while a scan is running, normal (60s) once finished.
-  // Honors the auto-reload toggle: if polling is OFF, do nothing.
+  // A running scan must be polled to completion and refresh the whole page 
even
+  // when Auto Refresh is off, otherwise the datanode sections stay stuck 
loading
+  // after the toggle is disabled. The toggle only governs the steady-state
+  // periodic reload once the scan has FINISHED.
   React.useEffect(() => {
-    if (!autoReload.isPolling) {
+    const scanInProgress = dnPendingDeletes.data.status !== "FINISHED";

Review Comment:
   This treats every status other than `FINISHED` as still running, so a stuck 
or failed scan may keep polling indefinitely. This matches the existing Auto 
Refresh behavior, so it does not need to be addressed in this PR. Handling 
`FAILED` or adding a timeout could be considered as a follow-up.



##########
hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/v2/pages/capacity/capacity.tsx:
##########
@@ -202,18 +202,27 @@ const Capacity: React.FC<object> = () => {
     }
   };
 
-  // Adjust the polling interval based on DN scan status:
+  // Keep the latest refresh callback in a ref so the interval below always 
calls
+  // the current closure instead of a stale one captured when the effect last 
ran.
+  const loadDataIfIdleRef = React.useRef(loadDataIfIdle);
+  loadDataIfIdleRef.current = loadDataIfIdle;
+
+  // Drive the DN pending-deletion scan through to completion:
   // fast (5s) while a scan is running, normal (60s) once finished.
-  // Honors the auto-reload toggle: if polling is OFF, do nothing.
+  // A running scan must be polled to completion and refresh the whole page 
even
+  // when Auto Refresh is off, otherwise the datanode sections stay stuck 
loading
+  // after the toggle is disabled. The toggle only governs the steady-state
+  // periodic reload once the scan has FINISHED.
   React.useEffect(() => {
-    if (!autoReload.isPolling) {
+    const scanInProgress = dnPendingDeletes.data.status !== "FINISHED";
+    if (autoReload.isPolling) {
+      autoReload.startPolling(scanInProgress ? PENDING_POLL_INTERVAL : 
AUTO_RELOAD_INTERVAL_DEFAULT);
       return;
     }
-    autoReload.startPolling(
-      dnPendingDeletes.data.status === "FINISHED"
-        ? AUTO_RELOAD_INTERVAL_DEFAULT
-        : PENDING_POLL_INTERVAL
-    );
+    if (scanInProgress) {
+      const timer = window.setInterval(() => loadDataIfIdleRef.current(), 
PENDING_POLL_INTERVAL);

Review Comment:
   This refreshes **all four Capacity** endpoints every 5 seconds, even when 
Auto Refresh is off. If the goal is only to clear the DN loading state once the 
scan finishes, would `dnPendingDeletes.refetch()` be enough? That may better 
match the toggle semantics and avoid unnecessary requests.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to