Skip to content

Clear connection map on clean up. (dfs 2834) #9111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2025

Conversation

alphaprinz
Copy link
Contributor

@alphaprinz alphaprinz commented Jun 21, 2025

Describe the Problem

When Notificator is done, it should clean the map containing the connections established during it's run.
Otherwise these stale connection would be used in the next run.
This scenario is relevant only to containerized (ie, does not affect NC).

Also-
-add more logs
-bump version 3.4.0 -> 3.4.1

Explain the Changes

  1. Clear connection's map on Notificator's cleanup.

Issues: Fixed #xxx / Gap #xxx

  1. https://issues.redhat.com/browse/DFBUGS-2834

Testing Instructions:

  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • Bug Fixes

    • Improved connection handling to prevent disconnect attempts on inactive connections.
    • Fixed clearing of connection mappings to ensure proper resource cleanup.
  • Chores

    • Updated the "node-rdkafka" dependency to version 3.4.1.
  • Style

    • Enhanced debug logging for Kafka notifications to provide clearer connection and error tracing.

Copy link

coderabbitai bot commented Jun 21, 2025

Walkthrough

The changes update the "node-rdkafka" dependency in package.json and enhance the KafkaNotificator class in src/util/notifications_util.js with additional debug logging, improved connection lifecycle handling, and minor method refinements. The connection clearing logic in Notificator is also reordered for clarity.

Changes

File(s) Change Summary
package.json Updated "node-rdkafka" dependency version from 3.4.0 to 3.4.1.
src/util/notifications_util.js Reordered connection clearing in Notificator. Added debug logs, refined connection handling, simplified callback in KafkaNotificator. Enhanced error handling and method checks.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant KafkaNotificator
    participant KafkaBroker

    Client->>KafkaNotificator: connect()
    KafkaNotificator->>KafkaBroker: Initiate connection
    KafkaBroker-->>KafkaNotificator: Connection result (success/failure)
    KafkaNotificator->>KafkaNotificator: Log connection status

    Client->>KafkaNotificator: promise_notify(notification)
    KafkaNotificator->>KafkaBroker: Send notification
    KafkaBroker-->>KafkaNotificator: Delivery report (success/failure)
    KafkaNotificator->>KafkaNotificator: Log send result

    Client->>KafkaNotificator: destroy()
    KafkaNotificator->>KafkaNotificator: Check if connected
    KafkaNotificator-->>KafkaBroker: flush & disconnect (if connected)
    KafkaNotificator->>KafkaNotificator: Log destruction status
Loading

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-06-23T13_04_35_568Z-debug-0.log


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2cef7cd and 7226ecb.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • package.json (1 hunks)
  • src/util/notifications_util.js (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • src/util/notifications_util.js
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Build Noobaa Image
  • GitHub Check: run-package-lock-validation
  • GitHub Check: run-jest-unit-tests
  • GitHub Check: Summary
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the Enable-Auto-Rebase Applying this label to a PR will cause it to auto-rebase (if other condition are met) label Jun 21, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/labeler.yml (1)

1-2: GitHub labeler configuration looks good but consider more specific rules.

The configuration will automatically apply the Enable-Auto-Rebase label to all PRs since the regex .* matches any branch name. This may be intentional for this repository's workflow.

Consider if you want more specific labeling rules based on branch patterns:

 Enable-Auto-Rebase:
-  - head-branch: '.*'
+  - head-branch: '^(feature|bugfix|hotfix)/.*'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8a9e2a8 and d61c5fc.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (4)
  • .github/labeler.yml (1 hunks)
  • .github/workflows/autolabel-prs.yml (1 hunks)
  • package.json (1 hunks)
  • src/util/notifications_util.js (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build-noobaa-image
  • GitHub Check: run-jest-unit-tests
  • GitHub Check: run-package-lock-validation
  • GitHub Check: Summary
🔇 Additional comments (6)
package.json (1)

110-110: ```shell
#!/bin/bash
npm view node-rdkafka versions --json
npm view [email protected] version


</details>
<details>
<summary>.github/workflows/autolabel-prs.yml (1)</summary>

`1-18`: **GitHub Actions workflow for PR labeling is well-configured.**

The workflow uses appropriate triggers, permissions, and actions versions. Using `pull_request_target` is correct for this use case as it allows the workflow to run with write permissions on external PRs.

</details>
<details>
<summary>src/util/notifications_util.js (4)</summary>

`109-110`: **LGTM! Connection map cleanup addresses the core issue.**

This change correctly implements the PR objective to clear the connection map during cleanup, preventing reuse of stale connections in containerized environments. The order is appropriate - clearing `connect_str_to_connection` before `notif_to_connect`.

---

`276-294`: **Enhanced Kafka connection logging improves troubleshooting.**

The additional debug logging provides better visibility into the Kafka connection lifecycle, including connection attempts, success/failure events, and error handling.

---

`307-315`: **Improved callback signature and notification logging.**

The callback signature was simplified by removing the unused `offset` parameter, and additional debug logging helps track notification success/failure with connection details.

---

`321-325`: **Connection state check prevents unnecessary operations.**

Adding `isConnected()` check before calling `flush()` and `disconnect()` prevents potential errors when the connection is already inactive, improving robustness.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

…lso add logs, bump version

Signed-off-by: Amit Prinz Setter <[email protected]>
@alphaprinz alphaprinz merged commit bb57299 into noobaa:master Jun 23, 2025
16 checks passed
alphaprinz added a commit to alphaprinz/noobaa-core that referenced this pull request Jun 23, 2025
…lso add logs, bump version (noobaa#9111)

Signed-off-by: Amit Prinz Setter <[email protected]>
alphaprinz added a commit to alphaprinz/noobaa-core that referenced this pull request Jun 24, 2025
…lso add logs, bump version (noobaa#9111)

Signed-off-by: Amit Prinz Setter <[email protected]>
@coderabbitai coderabbitai bot mentioned this pull request Jun 24, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enable-Auto-Rebase Applying this label to a PR will cause it to auto-rebase (if other condition are met) size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants