Skip to content

fix: enhance StartK8sStreamWithHeartBeat to prevent goroutine leaks and improve error handling#6960

Open
Ash-exp wants to merge 1 commit into
mainfrom
fix/nil-pointer-issue
Open

fix: enhance StartK8sStreamWithHeartBeat to prevent goroutine leaks and improve error handling#6960
Ash-exp wants to merge 1 commit into
mainfrom
fix/nil-pointer-issue

Conversation

@Ash-exp
Copy link
Copy Markdown
Contributor

@Ash-exp Ash-exp commented May 15, 2026

Description

Fixes https://github.com/devtron-labs/sprint-tasks/issues/2893

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit/api test cases.

Does this PR introduce a user-facing change?


Summary by Bito

  • Added import for async.Runnable from common-lib to enable enhanced goroutine management.
  • Modified PumpImpl struct to include asyncRunnable field and updated constructor to accept it.
  • Implemented sync.Once for idempotent stream closing in StartK8sStreamWithHeartBeat method.
  • Used sync.WaitGroup to synchronize heartbeat goroutine exit, ensuring function returns only after goroutine completes.
  • Wrapped heartbeat goroutine in asyncRunnable.Execute for panic recovery and metrics collection.

@sonarqubecloud
Copy link
Copy Markdown

@Ash-exp Ash-exp self-assigned this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants