Repository navigation
fix(instance): align persisted state labels across admin and dashboard - #7889
cloudbase-ai wants to merge 2 commits into
Conversation
Signed-off-by: cloudbase-ai <[email protected]>
Aias00
left a comment
There was a problem hiding this comment.
Review: label alignment for persisted instance states
The core of this change is correct, and I verified each claim against the code rather than the description:
InstanceStatusEnumstill pins0=DELETED,1=ONLINE,2=OFFLINE, andvalues().length == 3, so no new persisted code is introduced and historical rows stay valid.- The only production caller of
getNameByCodeisInstanceCheckService#getInstanceDataVisual: line data passes the literal0/1/2, and pie data passes arbitrary codes. So changing the fallback fromDELETED.nametoUNKNOWNcannot affect the timeout/recovery transitions indoCheck(), which compare againstgetCode()only. - Schema comments, the five dialect upgrade scripts, the H2 schema and the new contract doc all agree on the same code table.
- The frontend change is a clean bundle swap (
index.16dee401.jsdeleted,index.72158727.jsadded,index.htmlreference updated) with provenance recorded.
A note on the upgrade scripts: db/upgrade/2.7.2-upgrade-2.7.3-*.sql was introduced two days ago by #7673 and master is still 2.7.2-SNAPSHOT, so editing those files in place is fine here — nobody has consumed them from a release yet. MODIFY COLUMN / COMMENT ON COLUMN are both idempotent, and the definition repeats the existing type and NOT NULL with no default, so re-running is harmless.
Non-blocking comments
-
Pie data can emit duplicate
UNKNOWNslices.getInstanceDataVisualgroups by state code first, then maps each code to a name, so two distinct unrecognized codes (e.g.3and99) produce two separate entries that both render asUNKNOWN. If the contract is "unknown is a presentation fallback, not a state", group by the mapped name instead:Map<String, Long> pieData = instanceInfoVOS.stream() .filter(instance -> Objects.nonNull(instance.getInstanceState())) .collect(Collectors.groupingBy(vo -> InstanceStatusEnum.getNameByCode(vo.getInstanceState()), Collectors.counting()));
The new test only exercises a single unknown code, so this case is not covered today.
-
"UNKNOWN"is a magic string in a shared enum.shenyu-commonis consumed outside Admin, and the dashboard contract now depends on this exact literal. Consider exposing it as a documented constant (e.g.public static final String UNKNOWN_STATE_NAME = "UNKNOWN") so the doc, the enum andInstanceStatusEnumTestcannot drift apart. Keeping it out of the enum constants is the right call — a real constant would collide with the persisted-code space — but that rationale is worth a line in the Javadoc. -
Compatibility note for downstream consumers.
getNameByCodepreviously never returned a value outside the enum; after this change it can returnUNKNOWN. Anything downstream that switches on the returned string (or assumes it is a known state name) will now see a new value. The contract doc covers the semantics, but it deserves a line in the release notes too, since this is a public API inshenyu-common. -
Nit:
testExpiryAndRecoveryKeepPersistedStateCodesmutatesinstanceHeartBeatTimeOut/deleteTimeoutviaReflectionTestUtils. That is safe here because the class builds a freshInstanceCheckServiceper test withMockitoExtension(no shared Spring context), but if this test class ever moves to@SpringBootTestthose fields will leak into sibling tests.
LGTM apart from the above. The docs/instance-state-contract.md write-up is a good addition — it makes the retained-expired-record semantics explicit, which is exactly what was missing when the dashboard labeled 0 as unknown.
|
Heads-up: this branch now has merge conflicts with The conflict is almost certainly in the SQL migration set, which moves often: Could you rebase onto |
|
Heads-up: this branch conflicts with A large batch of admin/instance-related PRs merged in the last hour (#7762-series instance handling, #7780, #7776, #7962 namespace carry-over on appauth delete, #7855, #7888), several of which touch the same instance state / label persistence paths. Please rebase on |
Signed-off-by: cloudbase-ai <[email protected]>
Aias00
left a comment
There was a problem hiding this comment.
Re-approving after the master merge. The change only corrects the persisted state labels to match InstanceStatusEnum (0 = DELETED), and keeps every stored numeric value and transition untouched. The upgrade scripts only rewrite the column comment, so no data migration is required. The contract document makes the DELETED-vs-unknown distinction explicit, which is what the dashboard mismatch needed.
One coordination note: this PR also rebuilds the bundled dashboard artifacts, which overlaps the scope of #8003. Whichever lands first, please make sure the second one is dropped or rebased so the static bundle is not replaced twice.
|
@cloudbase-ai This PR is approved, but 1 checks are red: I inspected these lanes today and they fail for infrastructure reasons rather than on the diff — the Please rebase onto |
|
Hi @cloudbase-ai, this PR is already approved, but it currently cannot be merged. Here is the blocker and what is needed: Blocker What we need Once the branch is up to date and CI is green, we will squash-merge it. Thanks! |
Fixes #7694. Dashboard source companion: apache/shenyu-dashboard#727.
Instance state
0has always meantDELETEDin the backend, but the shipped dashboard and schema comments call it unknown. Unrecognized numeric states are also reported asDELETEDby the backend enum fallback.Keep the persisted contract (
0=DELETED,1=ONLINE,2=OFFLINE) and the existing timeout/recovery transitions. ReturnUNKNOWNfor unrecognized values without adding a new numeric state, correct fresh-schema comments, and update existing column descriptions in the 2.7.2→2.7.3 scripts. Historical stored values are not rewritten. Document that Deleted is a retained expired-instance state, rather than physical row removal.Include the generated Admin dashboard bundle from
apache/shenyu-dashboard@f239397e67c970c25a769f3b41ad3aaa7aca7a72(source PR apache/shenyu-dashboard#727). The source baseline is370cc40095ef4aa820449b7a9b736c7c98b6e9ab, which is already the baseline bundled by Admin. Only the JavaScript bundle and its HTML reference change; CSS and other assets are unchanged. Build provenance and SHA-256 are recorded indocs/instance-state-contract.md, and the copied static files were compared byte for byte with the build output. Please merge the dashboard source companion first.Validation:
./mvnw -pl shenyu-admin -am test -Dtest=InstanceStatusEnumTest,InstanceCheckServiceTest,InstanceInfoServiceTest,InstanceInfoMapperTest,InstanceControllerTest -Dsurefire.failIfNoSpecifiedTests=false -Drat.skip=true -Djacoco.skip=true -Dmaven.javadoc.skip=true— 54 tests, no failures/errors; Checkstyle passed../mvnw -pl shenyu-common,shenyu-admin apache-rat:check— passed.npm test— 58 suites, 340 tests passed; focused ESLint passed;npm run buildpassed.The mapper checks use H2. Native MySQL/OceanBase/PostgreSQL/openGauss/Oracle upgrade scripts and a live Admin heartbeat/dashboard end-to-end deployment were not run.