4b6817381b
CI (OpenClaw E2E) / openclaw test (push) Has been cancelled
CI / coverage-report (push) Has been cancelled
CI / test-kubernetes (push) Has been cancelled
CI / should-run-thorough (push) Has been cancelled
CI / test-thorough (cloudwatch-demo) (push) Has been cancelled
CI / test-thorough (flink-ecs) (push) Has been cancelled
CI / test-thorough (upstream-lambda) (push) Has been cancelled
CI / test-thorough (prefect-ecs-fargate) (push) Has been cancelled
Release / build-binaries (zip, opensre.exe, onefile, windows-latest, windows-x64) (push) Has been cancelled
Benchmark image — build + push to ECR (any adapter) / build + push (push) Has been cancelled
CI / quality (ubuntu-latest) (push) Has been cancelled
CI / test (tools-runtime) (push) Has been cancelled
CI / test (e2e-general) (push) Has been cancelled
CI / test (cli-runtime) (push) Has been cancelled
CI / test (e2e-provider-and-openclaw) (push) Has been cancelled
CI / test (integrations-and-misc) (push) Has been cancelled
Release / verify (push) Has been cancelled
Release / build-python-dist (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-15-intel, darwin-x64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, macos-latest, darwin-arm64) (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04, linux-x64) (push) Has been cancelled
Release / publish-release (push) Has been cancelled
Release / publish-main-release (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-checks (no-LLM) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
Interactive Shell Live (PR + post-merge) / turn-live shard ${{ matrix.shard_index }} (push) Has been cancelled
Release / prepare (push) Has been cancelled
Release / build-binaries (tar.gz, opensre, onedir, ubuntu-22.04-arm, linux-arm64) (push) Has been cancelled
Synthetic Deterministic Tests / Synthetic offline (deterministic) (push) Has been cancelled
127 lines
3.8 KiB
Python
127 lines
3.8 KiB
Python
"""RDS events tool — recent failover, maintenance, and configuration events."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import Any, cast
|
|
|
|
from core.tool_framework.tool_decorator import tool
|
|
from integrations.aws.aws_sdk_client import execute_aws_sdk_call
|
|
from integrations.rds import (
|
|
DEFAULT_RDS_REGION,
|
|
rds_extract_params,
|
|
rds_is_available,
|
|
)
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
DEFAULT_DURATION_MINUTES = 60
|
|
|
|
|
|
@tool(
|
|
name="describe_rds_events",
|
|
source="rds",
|
|
description=(
|
|
"Describe recent AWS RDS events for a DB instance — failovers, "
|
|
"maintenance windows, parameter changes, and backup events."
|
|
),
|
|
use_cases=[
|
|
"Investigating Multi-AZ failover events",
|
|
"Checking recent maintenance or parameter group changes",
|
|
"Tracing backup or recovery events around an incident",
|
|
],
|
|
requires=["db_instance_identifier"],
|
|
input_schema={
|
|
"type": "object",
|
|
"properties": {
|
|
"db_instance_identifier": {"type": "string"},
|
|
"region": {"type": "string", "default": DEFAULT_RDS_REGION},
|
|
"duration_minutes": {
|
|
"type": "integer",
|
|
"default": DEFAULT_DURATION_MINUTES,
|
|
"minimum": 1,
|
|
"maximum": 20160,
|
|
},
|
|
},
|
|
"required": ["db_instance_identifier"],
|
|
},
|
|
is_available=rds_is_available,
|
|
extract_params=rds_extract_params,
|
|
)
|
|
def describe_rds_events(
|
|
db_instance_identifier: str,
|
|
region: str = DEFAULT_RDS_REGION,
|
|
duration_minutes: int = DEFAULT_DURATION_MINUTES,
|
|
aws_backend: Any = None,
|
|
**_kwargs: Any,
|
|
) -> dict[str, Any]:
|
|
"""Describe recent RDS events for a DB instance.
|
|
|
|
When ``aws_backend`` is provided (FixtureAWSBackend in synthetic tests)
|
|
the call short-circuits to the backend so we never leak boto3 calls to
|
|
real AWS during scenario runs. Otherwise calls boto3 rds via
|
|
``execute_aws_sdk_call`` using the default boto3 credential chain.
|
|
"""
|
|
logger.info(
|
|
"[rds] describe_rds_events db=%s region=%s duration=%s",
|
|
db_instance_identifier,
|
|
region,
|
|
duration_minutes,
|
|
)
|
|
|
|
if aws_backend is not None:
|
|
return cast(
|
|
"dict[str, Any]",
|
|
aws_backend.describe_db_events(
|
|
db_instance_identifier=db_instance_identifier,
|
|
duration_minutes=duration_minutes,
|
|
region=region,
|
|
),
|
|
)
|
|
|
|
result = execute_aws_sdk_call(
|
|
service_name="rds",
|
|
operation_name="describe_events",
|
|
parameters={
|
|
"SourceIdentifier": db_instance_identifier,
|
|
"SourceType": "db-instance",
|
|
"Duration": duration_minutes,
|
|
},
|
|
region=region,
|
|
)
|
|
|
|
if not result.get("success"):
|
|
logger.error(
|
|
"[rds] describe_events failed for db=%s region=%s: %s",
|
|
db_instance_identifier,
|
|
region,
|
|
result.get("error"),
|
|
)
|
|
return {
|
|
"source": "rds",
|
|
"available": False,
|
|
"db_instance_identifier": db_instance_identifier,
|
|
"error": "Failed to describe RDS events. Check server logs for details.",
|
|
}
|
|
|
|
raw_events = (result.get("data") or {}).get("Events") or []
|
|
events = [
|
|
{
|
|
"date": event.get("Date"),
|
|
"message": event.get("Message"),
|
|
"categories": event.get("EventCategories", []),
|
|
"source_type": event.get("SourceType"),
|
|
}
|
|
for event in raw_events
|
|
]
|
|
|
|
return {
|
|
"source": "rds",
|
|
"available": True,
|
|
"db_instance_identifier": db_instance_identifier,
|
|
"duration_minutes": duration_minutes,
|
|
"total_events": len(events),
|
|
"events": events,
|
|
"error": None,
|
|
}
|