Skip to content

fix: update StartK8sStreamWithHeartBeat to use context for cancellation and improve error handling#6958

Open
Ash-exp wants to merge 1 commit intomainfrom
fix/mem-leak-issue
Open

fix: update StartK8sStreamWithHeartBeat to use context for cancellation and improve error handling#6958
Ash-exp wants to merge 1 commit intomainfrom
fix/mem-leak-issue

Conversation

@Ash-exp
Copy link
Copy Markdown
Contributor

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

Description

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

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 context.Context parameter to StartK8sStreamWithHeartBeat method in Pump interface and implementation for cancellation support.
  • Replaced regexp usage with strings.SplitN for log parsing and added handling for blank or malformed log lines to continue instead of aborting.
  • Improved goroutine management with context cancellation checks and changed done channel to chan struct{} for efficiency.
  • Added conditional flushing in heartbeat and main loop to avoid unnecessary operations on errors.
  • Updated the caller in k8sApplicationRestHandler.go to pass context and removed redundant stream close defer.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 1, 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.

1 participant