Skip to content

fix(admin): ignore the management server in the startup listener - #7789

Open
Sean-Walker0 wants to merge 1 commit into
apache:masterfrom
Sean-Walker0:fix/7775-startup-listener-management-server
Open

Sean-Walker0 wants to merge 1 commit into
apache:masterfrom
Sean-Walker0:fix/7775-startup-listener-management-server

Conversation

@Sean-Walker0

Copy link
Copy Markdown
Contributor

Fixes #7775

Modifications

ApplicationStartListener handled every WebServerInitializedEvent, so when the actuator management server (namespace "management") started on its own port, the listener called shenyuRunningModeService.start(host, managementPort, contextPath) a second time. In standalone mode this re-runs the checker setup; in cluster mode it schedules an extra recurring election task — both for a port that is not an Admin endpoint.

Events whose application context server namespace is "management" are now skipped:

if (event instanceof ServletWebServerInitializedEvent servletEvent
        && "management".equals(servletEvent.getApplicationContext().getServerNamespace())) {
    return;
}

The main server event (no namespace / "server") keeps the existing behavior unchanged.

Verifying this change

  • New ApplicationStartListenerTest#testIgnoresManagementServerEvent — delivers a management-namespace ServletWebServerInitializedEvent and asserts shenyuRunningModeService.start is never invoked for it. Red on the pre-fix code (the service was started with the management port, matching the issue's two-event reproduction), green after.
  • ./mvnw -pl shenyu-admin -am test -B -Dtest=ApplicationStartListenerTest — 4/4 green (3 pre-existing cases unchanged), module checkstyle clean.

Notes

  • Behavior change: a second start call for the management port no longer happens — that call had no valid purpose (the management server is a side-channel, not another Admin instance).
  • The issue notes a wrong advertised master port "has not been demonstrated in a deployed environment" — this fix removes the double-start unconditionally, without depending on event ordering.
  • Orthogonality: no open PR modifies ApplicationStartListener (verified against the file lists of all 106 open PRs).

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 (module-scoped: shenyu-admin targeted test class + checkstyle green; full-module suite left to CI as with the other admin PRs).

ApplicationStartListener handled every WebServerInitializedEvent, so
when the actuator management server (namespace "management") started
on its own port, the listener called shenyuRunningModeService.start a
second time with that port: standalone mode re-ran the checker setup
and cluster mode scheduled an extra recurring election task.

Skip events whose application context server namespace is
"management". Regression test delivers a management-namespace
ServletWebServerInitializedEvent and asserts the running mode service
is never started for it (red on the previous code, which started it
with the management port).

Fixes apache#7775

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

Correct fix. When a separate management (actuator) server is enabled, Spring fires a second WebServerInitializedEvent for it; the previous code re-ran the running-mode setup on that event, scheduling a duplicate election task bound to the management port. Narrowing on ServletWebServerInitializedEvent with server namespace "management" and returning early avoids the duplicate setup. The new testIgnoresManagementServerEvent test asserts start() is never called for that event.

CI is green on this branch.

This branch has not been deployed

No deployments
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] Admin startup listener initializes running mode for management server events

2 participants