Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions helm/robusta/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ lightActions:
- holmes_conversation
- holmes_issue_chat
- holmes_chat
- holmes_validate_toolset
- holmes_refresh_toolsets
- list_pods
- kubectl_describe
- fetch_resource_yaml
Expand Down
14 changes: 14 additions & 0 deletions src/robusta/core/model/base_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,20 @@ class HolmesConversationParams(HolmesParams):
include_tool_call_results: bool = True


class HolmesValidateToolsetParams(HolmesParams):
"""
:var yaml_config: Raw YAML string containing the toolset configuration, including the 'holmes:' wrapper.
"""

yaml_config: str


class HolmesRefreshToolsetsParams(HolmesParams):
"""Params for triggering a toolset status refresh via Holmes."""

pass


class NamespacedResourcesParams(ActionParams):
"""
:var name: Resource name
Expand Down
46 changes: 46 additions & 0 deletions src/robusta/core/playbooks/internal/ai_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
HolmesChatParams,
HolmesConversationParams,
HolmesIssueChatParams,
HolmesRefreshToolsetsParams,
HolmesValidateToolsetParams,
ResourceInfo,
)
from robusta.core.model.events import ExecutionBaseEvent
Expand All @@ -33,6 +35,8 @@
HolmesRequest,
HolmesResult,
HolmesResultsBlock,
HolmesValidateToolsetRequest,
HolmesValidateToolsetResponse,
)
from robusta.core.reporting.utils import convert_svg_to_png
from robusta.core.stream.utils import (
Expand Down Expand Up @@ -385,6 +389,48 @@ def holmes_chat(event: ExecutionBaseEvent, params: HolmesChatParams):
handle_holmes_error(e)


@action
def holmes_validate_toolset(event: ExecutionBaseEvent, params: HolmesValidateToolsetParams):
holmes_url = HolmesDiscovery.find_holmes_url(params.holmes_url)
if not holmes_url:
raise ActionException(
ErrorCodes.HOLMES_DISCOVERY_FAILED,
"Robusta couldn't connect to the Holmes client.",
)

try:
holmes_req = HolmesValidateToolsetRequest(yaml_config=params.yaml_config)
url = f"{holmes_url}/api/toolsets/validate"
result = requests.post(url, data=holmes_req.json())
result.raise_for_status()
holmes_response = HolmesValidateToolsetResponse(**json.loads(result.text))
event.response = {"success": True, **holmes_response.dict()}

except Exception as e:
logging.exception("Failed to validate toolset via Holmes", exc_info=True)
handle_holmes_error(e)


@action
def holmes_refresh_toolsets(event: ExecutionBaseEvent, params: HolmesRefreshToolsetsParams):
holmes_url = HolmesDiscovery.find_holmes_url(params.holmes_url)
if not holmes_url:
raise ActionException(
ErrorCodes.HOLMES_DISCOVERY_FAILED,
"Robusta couldn't connect to the Holmes client.",
)

try:
url = f"{holmes_url}/api/toolsets/refresh"
result = requests.post(url)
result.raise_for_status()
event.response = {"success": True}

except Exception as e:
logging.exception("Failed to refresh toolsets via Holmes", exc_info=True)
handle_holmes_error(e)


def stream_and_render_graphs(url, holmes_req, event):
with requests.post(
url,
Expand Down
17 changes: 17 additions & 0 deletions src/robusta/core/reporting/holmes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,20 @@ class HolmesChatResult(BaseModel):

class HolmesChatResultsBlock(BaseBlock):
holmes_result: Optional[HolmesChatResult]


class HolmesValidateToolsetRequest(BaseModel):
yaml_config: str = Field(
description="Raw YAML string containing the toolset configuration, including the 'holmes:' wrapper."
)


class HolmesValidateToolsetResult(BaseModel):
toolset_name: str
status: str = Field(description="Toolset status: 'valid' or 'invalid'")
error: Optional[str] = None
description: Optional[str] = None


class HolmesValidateToolsetResponse(BaseModel):
results: List[HolmesValidateToolsetResult]
7 changes: 6 additions & 1 deletion src/robusta/runner/config_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,12 @@ def __reload_playbook_packages(self, change_name):
)
# Kill the whole process group (which means this process and all of its descendant
# processes). The rest of the runner shutdown happens in robusta.runner.process_setup.
os.killpg(os.getpgid(0), signal.SIGTERM)
# os.killpg(os.getpgid(0), signal.SIGTERM)
if hasattr(os, "killpg"):
os.killpg(os.getpgid(0), signal.SIGTERM)
else:
os.kill(os.getpid(), signal.SIGTERM)


@classmethod
def __prepare_runtime_config(
Expand Down
Loading