Skip to content

[ISSUE #7695] Fix namespace-scoped instance history - #7855

Merged
Aias00 merged 1 commit into
apache:masterfrom
ymy4171:fix/7695-namespace-history
Oct 26, 2026
Merged

Aias00 merged 1 commit into
apache:masterfrom
ymy4171:fix/7695-namespace-history

Conversation

@ymy4171

@ymy4171 ymy4171 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #7695

Description

Instance history charts currently return global state counts when a
namespace is selected, while pie charts are filtered by namespace.

This PR adds separate histories per namespace and state while preserving
the aggregate view when no namespace is specified.

  • Retain the latest 20 samples per state.
  • Clean up histories for namespaces with no tracked instances.
  • Return zero-filled curves for missing namespaces without creating cache entries.
  • Synchronize history reads and writes.
  • Preserve one sample per scheduled check cycle.
  • Update two existing heartbeat tests to use valid JSON object metadata.

Validation

  • Before the fix, the namespace regression test failed:
    expected 2, actual 5.
  • Added tests for namespace isolation, aggregate counts, retention,
    cleanup, empty results, and per-state pie/history counts.
  • Local shenyu-admin module build passed:
    2053 tests run, 0 failures, 0 errors, 1 skipped.
  • Apache RAT license check passed.
  • The full-project clean install command below has not been run.

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

@ymy4171

ymy4171 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor Author

The HTTP integration job failed with a 180-second SocketTimeoutException
in RateLimiterPluginTest.setup(), while initializing the plugin through
/shenyu/plugin/saveOrUpdate.

This appears unrelated to the namespace history changes.
Could you please rerun the failed job to check whether it is transient?

Failure log:
https://github.com/apache/shenyu/actions/runs/39214778843/job/117952003776

Aias00
Aias00 previously approved these changes Oct 20, 2026

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good improvement to scope instance state history per namespace. The previous global stateHistoryMap collapsed counts across all namespaces; the new namespaceStateHistoryMap keyed by namespace — with a historyLock guarding both reads and writes, and a retainAll cleanup of namespaces that have no tracked instances — keeps the global aggregate and the per-namespace curves correct.

Highlights:

  • Tests cover namespace scoping, the 20-sample cap, namespace removal when instances disappear, and cross-namespace state separation.
  • getInstanceDataVisual(...) now reads the namespace-specific history under the same lock, so the global view and per-namespace view stay consistent.

CI note: pr_build is green. The two failing e2e checks (e2e and e2e-case e2e-http-sync-compose) are infrastructure flakes — their annotations show workflow-level exit code 1 / exit code 255 failures tied to the Node 20→24 forced runner migration, not assertion failures, and they do not touch the admin-side InstanceCheckService logic in this PR. They should recover on re-run.

Approving.

@Aias00

Aias00 commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Ping on state: this PR is approved on the code, but the required checks are red and it cannot be merged yet.

The failing jobs are e2e / e2e-case / list-contract / native-sql, which are currently failing across the repository and are tracked in #7970. The build job in this run does not fail on compilation: it stops at the gate step that consumes the e2e result ([[ "failure" == "success" ]] || exit -1), so there is nothing in this PR to fix for that.

No code change is expected from you. Once the shared e2e problem is resolved, please rerun the failed jobs (or push a trivial rebase) so the required checks go green, and this can be merged.

@Aias00

Aias00 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

@ymy4171 This PR is approved, but 9 checks are red: e2e, e2e-case (e2e-websocket-sync-compose, shenyu-e2e-case-websocket, :shenyu-example-spring-native-we..., e2e-case (e2e-http-sync-compose, shenyu-e2e-case-http, :shenyu-examples-http), e2e-case (e2e-grpc-sync-compose, shenyu-e2e-case-grpc, :shenyu-examples-grpc) (+5 more).

I inspected these lanes today and they fail for infrastructure reasons rather than on the diff — the integrated-test jobs die while starting their containers (Elasticsearch /_cat/health returning 000 until the job is cancelled), and the http lane also hits the known CachePluginTest.testMemoryModle / testRedisModle flake. The same jobs are red on master and on unrelated PRs right now.

Please rebase onto master and push (or ask for a re-run) so the checks execute again. If a case is still failing on a fresh run, paste the test name and I'll look properly.

@ymy4171

ymy4171 commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto the latest master and resolved the conflicts.
All CI workflows are now passing.

Could you please review the updated revision when convenient?
Thanks!

@Aias00 Aias00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Bucketing the instance state history by namespaceId (namespaceStateHistoryMap + historyLock) keeps per-namespace status timelines isolated, which is correct for multi-tenant deployments. Note: this edits InstanceCheckService.collectStateData()/constructor and overlaps with #7971 (retention cleanup) - please coordinate the rebase so the two changes land cleanly. Thanks!

@Aias00
Aias00 merged commit 16ec6f7 into apache:master Oct 26, 2026
55 checks passed
@Aias00 Aias00 added this to the 2.7.2 milestone Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Namespace instance history charts return global state counts

2 participants