Skip to content

fix(admin): forward instance heartbeats to the master admin (#7778) - #7797

Merged
Aias00 merged 1 commit into
apache:masterfrom
konlue:fix/instance-beat-forward
Oct 19, 2026
Merged

Aias00 merged 1 commit into
apache:masterfrom
konlue:fix/instance-beat-forward

Conversation

@konlue

@konlue konlue commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Fixes #7778.

Summary

In cluster mode, POST /instance/beat is absent from the ClusterForwardFilter forward list, so a follower handles the heartbeat locally: only that JVM's in-memory map is refreshed, while the master — the node that persists instance state — keeps aging the instance to OFFLINE.

Modifications

  • Add /instance/beat to the cluster forward-list, making the master the single authority for instance heartbeats: isMaster() short-circuits locally (no forwarding loops), and the filter forwards the POST body and headers verbatim, so master-side validation and handling are unchanged.
  • Scope is the beat endpoint only; dashboard reads (GET /instance, /instance/analysis/**) stay local.
  • Add ClusterForwardFilterTest, the cluster filter module's first test.

Verifying this change

  • ClusterForwardFilterTest: master handles locally; a follower forwards /instance/beat to the elected master with body and Content-Type intact and does not run the local chain; unlisted paths are handled locally; the shipped application.yml keeps the path in the forward list.

  • Red-green: removing the yml entry fails the yml assertion (instance heartbeats must be forwarded to the master admin); restoring it passes (4/4).

  • Targeted tests pass:

    ./mvnw -B -ntp -pl shenyu-admin test -Dtest=ClusterForwardFilterTest

    4/4 green.

  • Checkstyle passes:

    ./mvnw -B -ntp -pl shenyu-admin checkstyle:check

    clean.

Notes

Forward failures (master unreachable) behave like every other forwarded path — no new fallback is introduced here. /instance/beat is not in the shiro white list, and the filter forwards the original headers including credentials, so authentication behaviour is unchanged.

@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.

In cluster mode a worker admin should not persist instance heartbeats locally; forwarding /instance/beat to the master keeps the master authoritative for instance data, consistent with the existing forward-list pattern (shenyu-client, configs, etc.). The change is config-only plus the new ClusterForwardFilterTest, which covers local handling on master, forwarding to master, unlisted paths, and a YAML assertion that the forward-list includes /instance/beat.

CI is green on this branch.

@Aias00
Aias00 merged commit f4bc4af into apache:master Oct 19, 2026
54 checks passed
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] Heartbeats received by a follower Admin do not refresh the master instance state

2 participants