Skip to content

fix: handle net.Listen error in gRPC ExternalScaler goroutine (#323)#324

Merged
chrisliu1995 merged 1 commit into
openkruise:masterfrom
abhaygoudannavar:fix/handle-grpc-listen-error
Apr 9, 2026
Merged

fix: handle net.Listen error in gRPC ExternalScaler goroutine (#323)#324
chrisliu1995 merged 1 commit into
openkruise:masterfrom
abhaygoudannavar:fix/handle-grpc-listen-error

Conversation

@abhaygoudannavar
Copy link
Copy Markdown
Contributor

What this PR does

Fixes a nil-pointer panic in the gRPC ExternalScaler server goroutine caused by a discarded net.Listen error.

Problem

In main.go, the error returned by net.Listen was silently discarded:

lis, _ := net.Listen("tcp", scaleServerAddr)

When Listen fails (e.g. port conflict, permission denied), lis is nil. The subsequent call to grpcServer.Serve(nil) dereferences the nil listener and panics, crashing the controller-manager with no diagnostic log output.

Fix

  • Check the net.Listen error and log it with the bind address before exiting.
  • Improve the Serve error message to distinguish listen vs. serve failures.

Fixes #323

The error returned by net.Listen was silently discarded with '_'.
When Listen fails (port conflict, permission denied), the listener
is nil and grpcServer.Serve(nil) panics with a nil-pointer dereference,
crashing the controller-manager with no diagnostic output.

Now the error is checked and logged with the bind address before exiting.

Fixes openkruise#323
@kruise-bot kruise-bot requested review from FillZpp and zmberg April 8, 2026 22:11
@kruise-bot
Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign furykerry for approval by writing /assign @furykerry in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kruise-bot
Copy link
Copy Markdown

Welcome @abhaygoudannavar! It looks like this is your first PR to openkruise/kruise-game 🎉

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 40.53%. Comparing base (0974487) to head (d2f364b).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #324   +/-   ##
=======================================
  Coverage   40.53%   40.53%           
=======================================
  Files         112      112           
  Lines       12547    12547           
=======================================
  Hits         5086     5086           
  Misses       7051     7051           
  Partials      410      410           
Flag Coverage Δ
unittests 40.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chrisliu1995 chrisliu1995 merged commit 801f5a2 into openkruise:master Apr 9, 2026
8 of 9 checks passed
@abhaygoudannavar abhaygoudannavar deleted the fix/handle-grpc-listen-error branch April 9, 2026 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Discarded net.Listen error in gRPC ExternalScaler goroutine causes nil-pointer panic

3 participants