Skip to content

Bugfix: do not panic when a yurthub serving port is disabled - #2744

Open
Rad710 wants to merge 1 commit into
openyurtio:masterfrom
Rad710:fix-yurthub-panic-disabled-serving-port
Open

Bugfix: do not panic when a yurthub serving port is disabled#2744
Rad710 wants to merge 1 commit into
openyurtio:masterfrom
Rad710:fix-yurthub-panic-disabled-serving-port

Conversation

@Rad710

@Rad710 Rad710 commented Aug 11, 2026

Copy link
Copy Markdown

What type of PR is this?

/kind bug

What this PR does / why we need it:

SecureServingOptions.ApplyTo leaves the SecureServingInfo nil when BindPort <= 0 (which is how a serving port is switched off), but prepareServerServing then dereferenced it to set ClientCA/DisableHTTP2. As a result, starting yurthub with --proxy-secure-port=0 or --multiplexer-port=0 panics before the servers are even created.

This guards both the secure-proxy and multiplexer serving blocks with a nil check, matching RunYurtHubServers, which already skips a nil serving config. The secure-proxy case logs a Warning (in-cluster clients reach the apiserver through it, so disabling it has a real consequence); the multiplexer case logs an Info.

Default ports are positive, so the normal startup path is unchanged — only operators who explicitly set a serving port to 0 are affected, and for them the change turns a crash into a cleanly disabled listener.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Adds cmd/yurthub/app/config/serving_disabled_port_test.go covering both ports disabled, negative ports, only-the-multiplexer-off, a positive port still setting ClientCA, and that the defaults are positive. The test panics without the guard.

Does this PR introduce a user-facing change?

Fix a yurthub startup panic when a serving port (--proxy-secure-port or --multiplexer-port) is set to 0.

ApplyTo leaves SecureServingInfo nil when BindPort <= 0, but prepareServerServing dereferenced it, so --proxy-secure-port=0 or --multiplexer-port=0 panicked at startup. Guard both serving blocks with a nil check; default ports stay positive so normal startup is unchanged.

Signed-off-by: Rolando Medina Rosner <rolmedro@gmail.com>
@Rad710
Rad710 requested a review from a team as a code owner August 11, 2026 19:19
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant