This is an automated email from the ASF dual-hosted git repository.

lizhimins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new baf8a6a33 fix(alerts): stop calling a failed runtime read "not 
collected" (#6941)
baf8a6a33 is described below

commit baf8a6a3306940527feb9f2ecc8d061d5abb4d46
Author: bai mengxuan <[email protected]>
AuthorDate: Fri Nov 27 12:22:36 2026 +0800

    fix(alerts): stop calling a failed runtime read "not collected" (#6941)
---
 web/src/i18n/translations.ts                    |  4 ++++
 web/src/pages/ops/__tests__/AlertsPage.test.tsx | 13 ++++++++++++
 web/src/pages/ops/alerts.tsx                    | 27 ++++++++++++++++++++++---
 3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/web/src/i18n/translations.ts b/web/src/i18n/translations.ts
index 7d3f506be..c75821043 100644
--- a/web/src/i18n/translations.ts
+++ b/web/src/i18n/translations.ts
@@ -1122,6 +1122,10 @@ const translations: Record<string, Record<Lang, string>> 
= {
   'alerts.neverTriggered': { zh: '从未触发', en: 'Never' },
   'alerts.runtime': { zh: '运行态', en: 'Runtime' },
   'alerts.notCollected': { zh: '未采集', en: 'Not collected' },
+  'alerts.runtimeLoadFailed': {
+    zh: '运行状态读取失败,无法判断该规则当前是否在采集',
+    en: 'The rule runtime state could not be read, so whether this rule is 
collecting is unknown',
+  },
   'alerts.firingCount': { zh: '触发 {count}', en: 'Firing {count}' },
   'alerts.pendingCount': { zh: '待定 {count}', en: 'Pending {count}' },
   'alerts.duplicate': { zh: '复制', en: 'Duplicate' },
diff --git a/web/src/pages/ops/__tests__/AlertsPage.test.tsx 
b/web/src/pages/ops/__tests__/AlertsPage.test.tsx
index 85f219945..e9db83941 100644
--- a/web/src/pages/ops/__tests__/AlertsPage.test.tsx
+++ b/web/src/pages/ops/__tests__/AlertsPage.test.tsx
@@ -1448,4 +1448,17 @@ describe('AlertsPage', () => {
       ),
     );
   });
+
+  it('does not present a failed runtime read as a rule that was never 
collected', async () => {
+    vi.mocked(listAlertRuleRuntime).mockRejectedValue(new Error('runtime read 
failed'));
+    renderPage();
+
+    await screen.findByText('Broker disk usage');
+    // The read failed, so the column knows nothing about this rule - but 
"未采集" asserts the
+    // opposite, that collection is off.
+    expect(screen.queryByText('未采集')).not.toBeInTheDocument();
+    expect(
+      screen.getAllByLabelText('运行状态读取失败,无法判断该规则当前是否在采集').length,
+    ).toBeGreaterThan(0);
+  });
 });
diff --git a/web/src/pages/ops/alerts.tsx b/web/src/pages/ops/alerts.tsx
index e25ff85ef..0f8572b2f 100644
--- a/web/src/pages/ops/alerts.tsx
+++ b/web/src/pages/ops/alerts.tsx
@@ -235,6 +235,9 @@ const AlertsPageContent = ({ domain = 'CLUSTER', embedded = 
false }: AlertsPageP
   const [enabledFilter, setEnabledFilter] = useState<boolean | undefined>();
   const [rulesVersion, setRulesVersion] = useState(0);
   const [runtime, setRuntime] = useState<AlertRuleRuntime[]>([]);
+  // A runtime read that failed says nothing about the rules: the column must 
not claim their
+  // state was never collected, and the previous values would be just as 
misleading.
+  const [runtimeFailed, setRuntimeFailed] = useState(false);
   const [loading, setLoading] = useState(true);
   const [modalVisible, setModalVisible] = useState(false);
   const [editingRule, setEditingRule] = useState<AlertRule | null>(null);
@@ -451,8 +454,16 @@ const AlertsPageContent = ({ domain = 'CLUSTER', embedded 
= false }: AlertsPageP
         if (!cancelled) setLoading(false);
       });
     void listAlertRuleRuntime(domain)
-      .then(setRuntime)
-      .catch(() => undefined);
+      .then((next) => {
+        if (cancelled) return;
+        setRuntime(next);
+        setRuntimeFailed(false);
+      })
+      .catch(() => {
+        if (cancelled) return;
+        setRuntime([]);
+        setRuntimeFailed(true);
+      });
 
     return () => {
       cancelled = true;
@@ -818,7 +829,17 @@ const AlertsPageContent = ({ domain = 'CLUSTER', embedded 
= false }: AlertsPageP
       render: (_, record) => {
         const states = runtime.filter((state) => state.ruleId === record.id);
         if (!states.length)
-          return <span style={{ color: '#999' 
}}>{t('alerts.notCollected')}</span>;
+          return runtimeFailed ? (
+            <span
+              style={{ color: '#999' }}
+              title={t('alerts.runtimeLoadFailed')}
+              aria-label={t('alerts.runtimeLoadFailed')}
+            >
+              -
+            </span>
+          ) : (
+            <span style={{ color: '#999' }}>{t('alerts.notCollected')}</span>
+          );
         const firing = states.filter((state) => state.status === 
'FIRING').length;
         const pending = states.filter((state) => state.status === 
'PENDING').length;
         return (

Reply via email to