Skip to content

ROB-1323 cluster status when crashing#1830

Closed
RoiGlinik wants to merge 2 commits intomasterfrom
ROB-1323-cluster-status-when-crashing
Closed

ROB-1323 cluster status when crashing#1830
RoiGlinik wants to merge 2 commits intomasterfrom
ROB-1323-cluster-status-when-crashing

Conversation

@RoiGlinik
Copy link
Copy Markdown
Contributor

@RoiGlinik RoiGlinik commented May 29, 2025

sort sinks config before creating them. robusta sink to the end.

only the second commit is the change

Summary by CodeRabbit

  • Refactor

    • Improved code readability through formatting and restructuring of imports and expressions.
  • Bug Fixes

    • Adjusted the order of sink creation so that the Robusta sink is now initialized after other sinks.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2025

Walkthrough

The changes focus on code formatting and restructuring within a configuration module. Imports and expressions were reformatted for readability. In the sink construction process, sink configurations are now sorted to ensure that the Robusta sink is created last. No public interfaces or method signatures were altered.

Changes

File(s) Change Summary
src/robusta/model/config.py Reformatted imports and expressions for readability; added sorting to sink configs in sink creation.

Sequence Diagram(s)

sequenceDiagram
    participant SinksRegistry
    participant SinkConfigList
    participant RobustaSinkConfigWrapper

    SinksRegistry->>SinkConfigList: Retrieve all sink configs
    SinkConfigList->>SinksRegistry: Return configs
    SinksRegistry->>SinksRegistry: Sort configs (RobustaSinkConfigWrapper last)
    SinksRegistry->>SinksRegistry: Create sinks in sorted order
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link
Copy Markdown

@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)
src/robusta/model/config.py (1)

59-63: Apply the static analysis suggestion for better performance.

The list comprehension formatting is good, but there's a performance optimization opportunity.

Apply this diff to improve performance:

-        deleted_sink_names = [
-            sink_name
-            for sink_name in existing_sinks.keys()
-            if sink_name not in new_sink_names
-        ]
+        deleted_sink_names = [
+            sink_name
+            for sink_name in existing_sinks
+            if sink_name not in new_sink_names
+        ]
🧰 Tools
🪛 Ruff (0.11.9)

61-61: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c69ea7 and c598a98.

📒 Files selected for processing (1)
  • src/robusta/model/config.py (6 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
src/robusta/model/config.py

61-61: Use key in dict instead of key in dict.keys()

Remove .keys()

(SIM118)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: run_tests
  • GitHub Check: run_tests
  • GitHub Check: Deploy docs
🔇 Additional comments (10)
src/robusta/model/config.py (10)

12-15: LGTM! Import formatting improvement.

The multiline import formatting improves readability and follows Python best practices.


20-22: LGTM! Import formatting improvement.

Consistent with the previous import formatting change, this improves code readability.


34-36: LGTM! Logging message formatting improvement.

The multiline formatting improves readability of the warning message.


37-41: LGTM! List comprehension formatting improvement.

The multiline formatting makes the logic clearer and more readable.


92-95: LGTM! Conditional expression formatting improvement.

The multiline formatting makes the boolean logic clearer and easier to understand.


97-104: LGTM! Conditional and logging formatting improvements.

The multiline formatting improves readability of both the conditional expression and the logging statement.


151-153: LGTM! Function call formatting improvement.

The multiline formatting makes the function parameters clearer.


156-158: LGTM! Constructor call formatting improvement.

The multiline formatting improves readability of the constructor call.


173-177: LGTM! List comprehension formatting improvement.

The multiline formatting makes the complex list comprehension more readable and easier to understand.


71-76:

Details

✅ Verification successful

Verify the sorting logic correctly prioritizes RobustaSink last.

The sorting implementation correctly ensures that RobustaSinkConfigWrapper instances are placed at the end of the list. The boolean key isinstance(x, RobustaSinkConfigWrapper) returns False for non-Robusta sinks and True for Robusta sinks, effectively sorting them last since False < True.

This addresses the PR objective of handling cluster status during crashes by ensuring status is only sent after all other sinks are successfully created.

Let me verify that this sorting behavior is consistent throughout the codebase:


🏁 Script executed:

#!/bin/bash
# Description: Verify RobustaSinkConfigWrapper usage and ensure no other sorting logic conflicts

# Test: Search for other places where RobustaSinkConfigWrapper is used in sorting or ordering
rg -A 3 -B 3 "RobustaSinkConfigWrapper.*sort|sort.*RobustaSinkConfigWrapper"

# Test: Search for other sink creation or ordering logic that might conflict
ast-grep --pattern 'sorted($_, key=$_)'

Length of output: 1326


Sorting logic correctly prioritizes RobustaSinkConfigWrapper last

Verified that the boolean key isinstance(x, RobustaSinkConfigWrapper) places non-Robusta sinks (False) before Robusta sinks (True), and no other conflicting ordering logic exists elsewhere in the codebase.

• File: src/robusta/model/config.py, lines 71–76

new_sink_names = [sink_config.get_name() for sink_config in new_sinks_config]
# remove deleted sinks
deleted_sink_names = [sink_name for sink_name in existing_sinks.keys() if sink_name not in new_sink_names]
deleted_sink_names = [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@RoiGlinik I don't think you can change the order of the sinks
the order of the sinks matters

At least 2 places that I can think of:

  1. using stop on a sink - to the finding not continue to others
  2. Taking a value from one sink, and adding it to others (for example, taking the alert id from OpsGenie, and putting it in a Slack sink.

Please try to think of a different solution to solve this

@RoiGlinik RoiGlinik closed this Jun 5, 2025
@RoiGlinik RoiGlinik deleted the ROB-1323-cluster-status-when-crashing branch July 31, 2025 08:31
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.

2 participants