Skip to content

Rob 1254 holmes send toolset version json schema #416

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

moshemorad
Copy link
Contributor

@moshemorad moshemorad commented May 13, 2025

Summary by CodeRabbit

  • New Features
    • Toolsets now include version information, default status, and configuration schema details where available.
    • Added a feature flag to enable Holmes toolsets from SaaS environments.
  • Bug Fixes
    • Improved synchronization to ensure new metadata fields are correctly handled.
  • Tests
    • Enhanced test coverage to verify new toolset metadata fields and configuration schema handling.

@moshemorad moshemorad marked this pull request as ready for review May 14, 2025 07:25
Copy link
Contributor

coderabbitai bot commented May 14, 2025

Walkthrough

The changes introduce new metadata and schema-related attributes to toolset classes and their database models, including configuration schema and version information. Synchronization logic is updated to handle these attributes, and tests are expanded to validate the new fields and their correct handling in both basic and configuration-aware toolsets.

Changes

File(s) Change Summary
holmes/core/tools.py Added config_class and version as class variables to Toolset; extended ToolsetDBModel with version, config_schema, and is_default fields.
holmes/plugins/toolsets/grafana/base_grafana_toolset.py Removed type annotations for config_class in BaseGrafanaToolset, leaving it as a plain assignment.
holmes/plugins/toolsets/opensearch/opensearch.py Added config_class = OpenSearchConfig and version = "0.0.1" to OpenSearchToolset.
holmes/utils/holmes_sync_toolsets.py Updated holmes_sync_toolsets_status to include config_schema and version in toolset synchronization, generating schema from config_class if present; conditionally exclude these fields based on environment variable.
tests/test_holmes_sync_toolsets.py Enhanced tests to check for is_default, config_schema, and version. Added SampleConfig class and a new test for toolsets with configuration schema and version.
holmes/common/env_vars.py Added new boolean environment variable flag ENABLE_HOLMES_TOOLSETS_FROM_SAAS initialized to False.
holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py Added config_class = CoralogixConfig and version = "0.0.1" to BaseCoralogixToolset; added version = "0.0.1" to CoralogixLogsToolset.
holmes/plugins/toolsets/datadog.py Added config_class = DatadogConfig and version = "0.0.1" to DatadogToolset.
holmes/plugins/toolsets/grafana/toolset_grafana.py Added version = "0.0.1" to GrafanaToolset.
holmes/plugins/toolsets/grafana/toolset_grafana_loki.py Added version = "0.0.1" to BaseGrafanaLokiToolset.
holmes/plugins/toolsets/grafana/toolset_grafana_tempo.py Added version = "0.0.1" to BaseGrafanaTempoToolset.
holmes/plugins/toolsets/internet/internet.py Added version = "0.0.1" to InternetBaseToolset.
holmes/plugins/toolsets/kafka.py Added config_class = KafkaConfig and version = "0.0.1" to KafkaToolset.
holmes/plugins/toolsets/newrelic.py Added config_class = NewrelicConfig and version = "0.0.1" to NewRelicToolset.
holmes/plugins/toolsets/opensearch/opensearch_logs.py Added version = "0.0.1" to OpenSearchLogsToolset.
holmes/plugins/toolsets/opensearch/opensearch_traces.py Added version = "0.0.1" to OpenSearchTracesToolset.
holmes/plugins/toolsets/opensearch/opensearch_utils.py Added config_class = OpenSearchIndexConfig to BaseOpenSearchToolset.
holmes/plugins/toolsets/prometheus/prometheus.py Added config_class = PrometheusConfig and version = "0.0.1" to PrometheusToolset.
holmes/plugins/toolsets/rabbitmq/toolset_rabbitmq.py Added config_class = RabbitMQConfig and version = "0.0.1" to RabbitMQToolset.
holmes/plugins/toolsets/robusta/robusta.py Added version = "0.0.1" to RobustaToolset.

Sequence Diagram(s)

sequenceDiagram
    participant SyncScript as holmes_sync_toolsets_status
    participant Toolset as Toolset
    participant DBModel as ToolsetDBModel

    SyncScript->>Toolset: Inspect config_class and version
    alt Toolset has config_class
        SyncScript->>Toolset: Generate config_schema from config_class
    else Toolset has no config_class
        SyncScript->>Toolset: Set config_schema to None
    end
    SyncScript->>DBModel: Create ToolsetDBModel with config_schema, version, is_default, etc.
    DBModel-->>SyncScript: ToolsetDBModel instance ready for sync
Loading

Poem

In the warren of code, new fields appear,
Configs and versions now crystal clear.
Toolsets sync with schema in tow,
Tests hop along to let us know.
A rabbit’s delight, these changes bring,
Metadata blooms—what a wonderful spring! 🐇✨

Tip

⚡️ Faster reviews with caching
  • CodeRabbit now supports caching for code and dependencies, helping speed up reviews. This means quicker feedback, reduced wait times, and a smoother review experience overall. Cached data is encrypted and stored securely. This feature will be automatically enabled for all accounts on May 16th. To opt out, configure Review - Disable Cache at either the organization or repository level. If you prefer to disable all data retention across your organization, simply turn off the Data Retention setting under your Organization Settings.

Enjoy the performance boost—your workflow just got faster.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8bc927f and 0b03901.

📒 Files selected for processing (16)
  • holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py (2 hunks)
  • holmes/plugins/toolsets/datadog.py (1 hunks)
  • holmes/plugins/toolsets/grafana/toolset_grafana.py (1 hunks)
  • holmes/plugins/toolsets/grafana/toolset_grafana_loki.py (1 hunks)
  • holmes/plugins/toolsets/grafana/toolset_grafana_tempo.py (1 hunks)
  • holmes/plugins/toolsets/internet/internet.py (1 hunks)
  • holmes/plugins/toolsets/kafka.py (1 hunks)
  • holmes/plugins/toolsets/newrelic.py (1 hunks)
  • holmes/plugins/toolsets/opensearch/opensearch.py (1 hunks)
  • holmes/plugins/toolsets/opensearch/opensearch_logs.py (1 hunks)
  • holmes/plugins/toolsets/opensearch/opensearch_traces.py (1 hunks)
  • holmes/plugins/toolsets/opensearch/opensearch_utils.py (1 hunks)
  • holmes/plugins/toolsets/prometheus/prometheus.py (1 hunks)
  • holmes/plugins/toolsets/rabbitmq/toolset_rabbitmq.py (1 hunks)
  • holmes/plugins/toolsets/robusta/robusta.py (1 hunks)
  • holmes/utils/holmes_sync_toolsets.py (2 hunks)
✅ Files skipped from review due to trivial changes (12)
  • holmes/plugins/toolsets/robusta/robusta.py
  • holmes/plugins/toolsets/grafana/toolset_grafana.py
  • holmes/plugins/toolsets/opensearch/opensearch_logs.py
  • holmes/plugins/toolsets/rabbitmq/toolset_rabbitmq.py
  • holmes/plugins/toolsets/opensearch/opensearch_traces.py
  • holmes/plugins/toolsets/internet/internet.py
  • holmes/plugins/toolsets/grafana/toolset_grafana_tempo.py
  • holmes/plugins/toolsets/prometheus/prometheus.py
  • holmes/plugins/toolsets/newrelic.py
  • holmes/plugins/toolsets/grafana/toolset_grafana_loki.py
  • holmes/plugins/toolsets/datadog.py
  • holmes/plugins/toolsets/coralogix/toolset_coralogix_logs.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • holmes/plugins/toolsets/opensearch/opensearch.py
  • holmes/utils/holmes_sync_toolsets.py
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
🔇 Additional comments (2)
holmes/plugins/toolsets/kafka.py (1)

481-483: Changes add important metadata attributes for toolset versioning and configuration.

The addition of config_class and version attributes enables explicit metadata about the configuration model and version identifier for the Kafka toolset. These additions align with the broader update across toolsets to standardize metadata representation and support schema handling.

Consider adopting semantic versioning principles (major.minor.patch) for future version updates as your toolset evolves, which will help communicate the nature of changes to consumers of this toolset.

holmes/plugins/toolsets/opensearch/opensearch_utils.py (1)

22-24: Addition of config_class aligns with standardization effort.

This change explicitly declares OpenSearchIndexConfig as the configuration model for BaseOpenSearchToolset, which formalizes the relationship that was already implicit in the implementation. The change supports the broader effort to standardize configuration schema references across toolsets.

Consider whether a version attribute should also be added to this class. According to the PR summary, related OpenSearch toolset classes were enhanced with both config_class and version attributes. If applicable, you might want to add a version identifier to complete the standardization.

✨ 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.

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
Contributor

@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: 1

🧹 Nitpick comments (2)
tests/test_holmes_sync_toolsets.py (2)

322-325: Enhance schema validation in the test.

The test verifies basic schema properties but could be more thorough in validating the complete schema structure.

Add more detailed schema validation:

    config_schema = toolset_data["config_schema"]
    assert config_schema is not None
    assert config_schema["type"] == "object"
    assert config_schema["title"] == "SampleConfig"
+    # Validate properties structure
+    assert "properties" in config_schema
+    assert "param" in config_schema["properties"]
+    assert config_schema["properties"]["param"]["type"] == "string"
+    # Validate required fields
+    assert "required" in config_schema
+    assert "param" in config_schema["required"]

306-326: Consider adding negative test cases.

While the current test covers the happy path scenario, it would be beneficial to add test cases for error scenarios as well.

For example, you could add a test for invalid configuration classes or version formats:

def test_sync_toolsets_with_invalid_config_class(mock_dal, mock_config, sample_toolset):
    # Use a non-BaseModel class as config_class
    class InvalidConfig:
        param: str
        
    SampleToolset.config_class = InvalidConfig
    mock_config.create_tool_executor.return_value = Mock(toolsets=[sample_toolset])
    
    # Should handle gracefully or raise appropriate error
    holmes_sync_toolsets_status(mock_dal, mock_config)
    
    # Cleanup
    SampleToolset.config_class = None
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3ff1012 and ff4de26.

📒 Files selected for processing (5)
  • holmes/core/tools.py (3 hunks)
  • holmes/plugins/toolsets/grafana/base_grafana_toolset.py (2 hunks)
  • holmes/plugins/toolsets/opensearch/opensearch.py (1 hunks)
  • holmes/utils/holmes_sync_toolsets.py (2 hunks)
  • tests/test_holmes_sync_toolsets.py (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
holmes/plugins/toolsets/grafana/base_grafana_toolset.py (1)
holmes/plugins/toolsets/grafana/common.py (1)
  • GrafanaConfig (9-21)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
  • GitHub Check: build (3.11)
  • GitHub Check: build (3.10)
  • GitHub Check: build (3.9)
  • GitHub Check: build (3.12)
🔇 Additional comments (9)
holmes/plugins/toolsets/opensearch/opensearch.py (1)

188-188: LGTM: Added config_class attribute to associate with configuration schema

This change explicitly associates the OpenSearchToolset with its configuration model, enabling the toolset to expose its configuration schema during synchronization.

holmes/plugins/toolsets/grafana/base_grafana_toolset.py (2)

2-2: LGTM: Simplified typing imports

The import statement has been simplified by removing unnecessary type annotations that are no longer needed.


15-15: LGTM: Updated config_class attribute declaration

Changed from a typed class variable to a simple attribute assignment while maintaining the same functionality. This matches the pattern used in other toolset classes.

holmes/utils/holmes_sync_toolsets.py (2)

54-56: LGTM: Added schema extraction logic

Good implementation for extracting the JSON schema from the toolset's configuration class if it exists, with proper null handling for cases where config_class is not defined.


67-68: LGTM: Added new fields to toolset database model

Properly adds the configuration schema and version information to the toolset database model, allowing this metadata to be persisted.

holmes/core/tools.py (2)

332-334: LGTM: Added new class variables to Toolset

Added config_class and version class variables to the Toolset base class to support configuration schema and version information. These are appropriately marked as optional.


578-580: LGTM: Extended ToolsetDBModel with new fields

Added corresponding fields to the database model to store configuration schema, version information, and default status. The fields have appropriate types and optionality.

tests/test_holmes_sync_toolsets.py (2)

36-38: Good addition of Pydantic model for testing configuration schemas.

The SampleConfig class provides a clean way to test the JSON schema generation from configuration classes in toolsets.


75-77: Appropriate test coverage for default values.

Good additions to verify that the new fields have expected default values when not explicitly set.

@moshemorad moshemorad requested review from nherment and arikalon1 May 14, 2025 10:11
Copy link
Contributor

Results of HolmesGPT evals

Test suite Test case Status
ask_holmes 01_how_many_pods ⚠️
ask_holmes 02_what_is_wrong_with_pod
ask_holmes 02_what_is_wrong_with_pod_LOKI
ask_holmes 03_what_is_the_command_to_port_forward
ask_holmes 04_related_k8s_events
ask_holmes 05_image_version
ask_holmes 06_explain_issue
ask_holmes 07_high_latency
ask_holmes 07_high_latency_LOKI
ask_holmes 08_sock_shop_frontend
ask_holmes 09_crashpod
ask_holmes 10_image_pull_backoff
ask_holmes 11_init_containers
ask_holmes 12_job_crashing
ask_holmes 12_job_crashing_CORALOGIX
ask_holmes 12_job_crashing_LOKI
ask_holmes 13_pending_node_selector
ask_holmes 14_pending_resources
ask_holmes 15_failed_readiness_probe
ask_holmes 16_failed_no_toolset_found
ask_holmes 17_oom_kill
ask_holmes 18_crash_looping_v2
ask_holmes 19_detect_missing_app_details
ask_holmes 20_long_log_file_search
ask_holmes 20_long_log_file_search_LOKI
ask_holmes 21_job_fail_curl_no_svc_account ⚠️
ask_holmes 22_high_latency_dbi_down ⚠️
ask_holmes 23_app_error_in_current_logs
ask_holmes 23_app_error_in_current_logs_LOKI
ask_holmes 24_misconfigured_pvc
ask_holmes 25_misconfigured_ingress_class ⚠️
ask_holmes 26_multi_container_logs ⚠️
ask_holmes 27_permissions_error_no_helm_tools ⚠️
ask_holmes 28_permissions_error_helm_tools_enabled
ask_holmes 29_events_from_alert_manager
ask_holmes 30_basic_promql_graph_cluster_memory
ask_holmes 31_basic_promql_graph_pod_memory
ask_holmes 32_basic_promql_graph_pod_cpu
ask_holmes 33_http_latency_graph
ask_holmes 34_memory_graph
ask_holmes 35_tempo
ask_holmes 36_argocd_find_resource
ask_holmes 37_argocd_wrong_namespace ⚠️
ask_holmes 38_rabbitmq_split_head
ask_holmes 39_failed_toolset
ask_holmes 40_disabled_toolset
ask_holmes 41_setup_argo
investigate 01_oom_kill
investigate 02_crashloop_backoff
investigate 03_cpu_throttling
investigate 04_image_pull_backoff
investigate 05_crashpod
investigate 05_crashpod_LOKI
investigate 06_job_failure
investigate 07_job_syntax_error
investigate 08_memory_pressure
investigate 09_high_latency
investigate 10_kube_controller_manager_down ⚠️
investigate 11_KubeDeploymentReplicasMismatch
investigate 12_KubePodCrashLooping
investigate 13_KubePodNotReady
investigate 14_Watchdog
investigate 15_tempo

Legend

  • ✅ the test was successful
  • ⚠️ the test failed but is known to be flakky or known to fail
  • ❌ the test failed and should be fixed before merging the PR

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.

1 participant