You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by "unbridled-41 (via GitHub)" <gi...@apache.org> on 2026/10/09 17:20:52 UTC

[PR] fix(cluster): read the live broker config before the dialog may submit it [rocketmq-dashboard]

unbridled-41 opened a new pull request, #5898:
URL: https://github.com/apache/rocketmq-dashboard/pull/5898

   ### Which Issue(s) This PR Fixes
   
   Fixes #5897
   
   ### Problem / Evidence
   
   The Broker tab is fed by `GET /clusters/registry`, which reports topology only: `RocketMQClusterProvider.buildClusterVO` (`:202-216`) never sets `config`, and `ClusterVO.config` has no builder default, so every row of that tab carries `config: null`. `handleConfigOpen` turned that into concrete values through its `??` fallbacks:
   
   ```ts
   // web/src/pages/cluster/index.tsx (before)
   const cfg: ClusterConfig = cluster.config ?? ({} as ClusterConfig);
   configForm.setFieldsValue({
     flushDiskType: cfg.flushDiskType ?? 'ASYNC_FLUSH',
     maxMessageSizeMB: Math.round((cfg.maxMessageSize ?? 4194304) / 1048576),
     fileReservedTime: cfg.fileReservedTime ?? 72,
     writeQueueNums: cfg.writeQueueNums ?? 8,
     readQueueNums: cfg.readQueueNums ?? 8,
     brokerPermission: cfg.brokerPermission ?? 6,
     ...
   });
   ```
   
   and `buildConfigUpdateRequest` spreads the form into the request, which `ClusterService.applyConfig` (`:362-390`) applies to **every broker of the cluster** and persists. Opening the dialog and pressing 确定 without touching a field therefore rewrote eight live broker settings - flushDiskType SYNC_FLUSH -> ASYNC_FLUSH, fileReservedTime 168 h -> 72 h (segments deleted earlier), maxMessageSize -> 4 MB, defaultTopicQueueNums -> 8, brokerPermission -> 6, both auto-create switches -> false - none of which the operator chose.
   
   The data is available: `GET /clusters/{id}` runs the same `enrichWithLiveConfig` the instance-scoped list uses, which is why the sibling 配置差异 dialog on the same row can show the real `flushDiskType`. The suite could not see it because the fixture supplies a full config (`ClusterPage.test.tsx` `buildCluster()`), which is not what the registry endpoint returns.
   
   ### Root cause / Fix
   
   The dialog treated "no config on the row" as "defaults", and its source endpoint by design never carries one. Load the cluster detail when the dialog opens (the row's config stays the immediate fill when present, so the instance-scoped behaviour is unchanged), fill the form from the live config, and when no config can be read at all show the reason and disable 确定 instead of offering a form that would invent one.
   
   ### Priority and scoring
   
   **PRIORITY 88** — impact 36/40 (a silent destructive write to a production cluster: durability, retention, message size, default queue count, permission), blast radius 18/20 (any cluster opened through the Broker tab that way), reproducibility 18/20 (deterministic client-side payload, pinned by the new test), maintenance value 16/20 (removes a "guess and write" path).
   
   **FIX_CONFIDENCE 85** — the missing data source and the available one are both verified in code; the only judgement is the unreadable-config UX, which fails safe (no submit).
   
   ### Tests
   
   `cd web && npx vitest run src/pages/cluster/__tests__/ClusterPage.test.tsx` -> `Tests 32 passed`.
   
   | Test | Before | After |
   |---|---|---|
   | `fills the broker config dialog from the live cluster detail, not from fabricated defaults` | FAIL (detail never requested; form showed the 72 h fallback instead of the live 168 h) | PASS |
   | `refuses to edit a broker config it could not read instead of submitting defaults` | FAIL (no reason shown, 确定 enabled) | PASS |
   
   `npx eslint` reports no errors; `npx tsc -b` passes. The pre-existing config-preview cases still pass (the row-config path is unchanged).
   
   ### Risk
   
   One extra `GET /clusters/{id}` per dialog open (the same call the instance-scoped list already makes), and a new read-only state when the broker config cannot be read. Nothing else changes: the request shape, the preview, the submit path and the instance-scoped rows are untouched.
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): read the live broker config before the dialog may submit it [rocketmq-dashboard]

Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #5898:
URL: https://github.com/apache/rocketmq-dashboard/pull/5898#issuecomment-6090899701

   ### Follow-up review of this fix: the live read could land in the wrong dialog
   
   `loadLiveConfig` committed its response unconditionally, so a read that was still in flight when the operator cancelled the dialog over cluster A and opened cluster B instead would:
   
   - write A's config into the shared form that B's dialog is now showing, and
   - call `setConfigUnavailable(false)` / `setConfigLoading(false)`, clearing B's refusal warning and re-enabling **OK** over values that were never read for B.
   
   That is the same class of bug this PR fixes (submitting values nobody read), just triggered by a race instead of by a missing endpoint. Commit `fc7003b5` closes it in this branch (first commit `5737a1bd` untouched, no force-push):
   
   - added a `configLoadRequest` generation next to the page's existing `configPreviewRequest` and applied the documented pattern (`begin()` on issue, `isCurrent()` before committing, `invalidate()` when the dialog closes / on unmount);
   - `handleConfigOpen` passes the token to `loadLiveConfig`, which returns before touching `applyConfigFormValues`, `setSelectedCluster`, `setConfigUnavailable` or `setConfigLoading` when the token is stale;
   - the modal's `onCancel` now invalidates it alongside `configPreviewRequest`.
   
   New regression test `drops a live config response for a dialog the operator already left`: cluster A's `getCluster` never settles, the dialog is cancelled, cluster B's read rejects, then A resolves late — B must keep its warning and keep **OK** disabled.
   
   Red/green, both observed locally:
   
   ```
   # without the isCurrent guard
   cd web && npx vitest run src/pages/cluster/__tests__/ClusterPage.test.tsx -t 'drops a live config response'
    Tests  1 failed | 32 skipped (33)        <- B's OK was re-enabled by A's response
   
   # with fc7003b5
   cd web && npx vitest run src/pages/cluster/__tests__/ClusterPage.test.tsx
    Test Files  1 passed (1)
         Tests  33 passed (33)
   ```
   
   `npx tsc -b` and `npx eslint src/pages/cluster/index.tsx src/pages/cluster/__tests__/ClusterPage.test.tsx` are clean.
   
   Branch `fix/broker-config-dialog-live-values`, HEAD `fc7003b5` (on top of `5737a1bd`).


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): read the live broker config before the dialog may submit it [rocketmq-dashboard]

Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 closed pull request #5898: fix(cluster): read the live broker config before the dialog may submit it
URL: https://github.com/apache/rocketmq-dashboard/pull/5898


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): read the live broker config before the dialog may submit it [rocketmq-dashboard]

Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #5898:
URL: https://github.com/apache/rocketmq-dashboard/pull/5898#issuecomment-6086389301

   ### CI status of this PR
   
   `Backend Tests (Java 21)` — **pass**; the change-specific commands and their results are in the Tests section of the description.
   
   The four remaining red jobs are red for every branch, including `rocketmq-studio` itself:
   
   - `Backend Build (Java 21)` — the `binary-license-gate` antrun step fails on a list of third-party jars (`spring-ai-*`, `swagger-ui`, `tencentcloud-sdk-*`, `zstd-jni`, ... : "missing complete upstream LICENSE/COPYING; a POM name or link is not a substitute"). This PR touches no build configuration; tracked by #5341.
   - `Frontend Build (Node 20)` / `Frontend Docker Build` — the frontend licence manifest check fails the same way on branches that do not touch `web/` at all; tracked by #5346.
   - `rmqctl Build (Go)` — `cmd` `TestMessageQueryCompletenessWarningTest` yaml subtests: `got {"items":[{"size":"3",...}]}, want {"size":3,...}`, i.e. the YAML renderer writes numbers as quoted strings where the test expects integer literals. Reproduced locally with `cd rmqctl && go test ./cmd/` from a checkout whose `rmqctl/` tree is byte-identical to `rocketmq-studio`'s, and owned by open PR #5850 ("keep yaml numbers unquoted").


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(cluster): read the live broker config before the dialog may submit it [rocketmq-dashboard]

Posted by "unbridled-41 (via GitHub)" <gi...@apache.org>.
unbridled-41 commented on PR #5898:
URL: https://github.com/apache/rocketmq-dashboard/pull/5898#issuecomment-6091309250

   ### Verification on the final commit (branch + commit + command results)
   
   Every command from the description re-run on a fresh worktree of this branch (`git worktree add <dir> fork/<branch>`, no local modifications), at commit `fc7003b5f9`:
   
   | command | exit | result |
   | --- | --- | --- |
   | `cd web && npx vitest run src/pages/cluster/__tests__/ClusterPage.test.tsx` | 0 | `Test Files  1 passed (1) · Tests  33 passed (33)` |
   
   CI note: on this repository the `Backend Build` (binary-license-gate), `Frontend Build` / `Frontend Docker Build` (licence manifest) and `rmqctl Build` (YAML renderer quoting) jobs are red for every branch, trunk included; the module-level commands above are unaffected.
   


-- 
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: commits-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org