Skip to content
Closed
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: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ hybridcloud: 0034_drop_webhookpayload_priority_index

insights: 0001_squashed_0002_backfill_team_starred

investigations: 0005_add_investigation_summary_fields
investigations: 0006_add_investigation_orchestration

monitors: 0001_squashed_0013_delete_monitor_is_muted_field

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
"@types/react-lazyload": "3.2.3",
"@types/react-select": "4.0.18",
"@types/reflux": "0.4.1",
"@xyflow/react": "^12.11.3",
"ansi-to-react": "^6.1.6",
"base64-arraybuffer": "^1.0.1",
"cbor2": "^1.12.0",
Expand Down
85 changes: 85 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions src/sentry/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@
from sentry.investigations.endpoints.organization_investigation_index import (
OrganizationInvestigationsIndexEndpoint,
)
from sentry.investigations.endpoints.organization_investigation_orchestration import (
OrganizationInvestigationOrchestrationCommandsEndpoint,
OrganizationInvestigationOrchestrationEndpoint,
)
from sentry.investigations.endpoints.organization_investigation_parameters import (
OrganizationInvestigationParametersEndpoint,
)
Expand Down Expand Up @@ -2460,6 +2464,16 @@ def create_group_urls(name_prefix: str) -> list[URLPattern | URLResolver]:
OrganizationInvestigationsDetailsEndpoint.as_view(),
name="sentry-api-0-organization-investigation-details",
),
re_path(
r"^(?P<organization_id_or_slug>[^/]+)/investigations/(?P<investigation_id>[^/]+)/orchestration/$",
OrganizationInvestigationOrchestrationEndpoint.as_view(),
name="sentry-api-0-organization-investigation-orchestration",
),
re_path(
r"^(?P<organization_id_or_slug>[^/]+)/investigations/(?P<investigation_id>[^/]+)/orchestration/commands/$",
OrganizationInvestigationOrchestrationCommandsEndpoint.as_view(),
name="sentry-api-0-organization-investigation-orchestration-commands",
),
re_path(
r"^(?P<organization_id_or_slug>[^/]+)/investigations/(?P<investigation_id>[^/]+)/blocks/$",
OrganizationInvestigationBlocksEndpoint.as_view(),
Expand Down
3 changes: 3 additions & 0 deletions src/sentry/deletions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ def load_defaults(manager: DeletionTaskManager) -> None:
manager.register(investigations.InvestigationBlockExecutionProject, BulkModelDeletionTask)
manager.register(investigations.InvestigationBlockParameter, BulkModelDeletionTask)
manager.register(investigations.InvestigationFavoriteUser, BulkModelDeletionTask)
manager.register(investigations.InvestigationOrchestrationCommand, BulkModelDeletionTask)
manager.register(investigations.InvestigationOrchestrationEvent, BulkModelDeletionTask)
manager.register(investigations.InvestigationOrchestrationRun, defaults.InvestigationOrchestrationRunDeletionTask)
manager.register(investigations.InvestigationProject, BulkModelDeletionTask)
manager.register(monitors.Monitor, defaults.MonitorDeletionTask)
manager.register(monitors.MonitorEnvironment, defaults.MonitorEnvironmentDeletionTask)
Expand Down
26 changes: 26 additions & 0 deletions src/sentry/deletions/defaults/investigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,32 @@
InvestigationBlockExecutionProject,
InvestigationBlockParameter,
InvestigationFavoriteUser,
InvestigationOrchestrationCommand,
InvestigationOrchestrationEvent,
InvestigationOrchestrationRun,
InvestigationParameter,
InvestigationProject,
)


class InvestigationOrchestrationRunDeletionTask(ModelDeletionTask[InvestigationOrchestrationRun]):
mark_in_progress_default = False

def get_child_relations(self, instance: InvestigationOrchestrationRun) -> list[BaseRelation]:
return [
ModelRelation(
InvestigationOrchestrationEvent,
{"orchestration_run_id": instance.id},
BulkModelDeletionTask,
),
ModelRelation(
InvestigationOrchestrationCommand,
{"orchestration_run_id": instance.id},
BulkModelDeletionTask,
),
]


class InvestigationBlockExecutionDeletionTask(ModelDeletionTask[InvestigationBlockExecution]):
mark_in_progress_default = False

Expand Down Expand Up @@ -63,4 +84,9 @@ def get_child_relations(self, instance: Investigation) -> list[BaseRelation]:
ModelRelation(
InvestigationParameter, {"investigation_id": instance.id}, BulkModelDeletionTask
),
ModelRelation(
InvestigationOrchestrationRun,
{"investigation_id": instance.id},
InvestigationOrchestrationRunDeletionTask,
),
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import Any

from django.db.models import Q
from drf_spectacular.utils import extend_schema
from rest_framework import status
Expand All @@ -18,6 +20,7 @@
from sentry.investigations.models import (
Investigation,
InvestigationSourceType,
InvestigationOrchestrationRun,
InvestigationStatus,
)
from sentry.investigations.services import (
Expand Down Expand Up @@ -99,8 +102,27 @@ def post(self, request: Request, organization: Organization) -> Response:
viewable_ids = investigation_ids_with_project_access(
existing, request.access.accessible_project_ids
)
orchestration_by_investigation = {
investigation_id: {
"phase": phase,
"status": run_status,
"heartbeatAt": heartbeat_at,
"notebookRevision": notebook_revision,
}
for investigation_id, phase, run_status, heartbeat_at, notebook_revision in (
InvestigationOrchestrationRun.objects.filter(
investigation_id__in=[investigation.id for investigation in existing]
).values_list(
"investigation_id",
"phase",
"status",
"heartbeat_at",
"notebook_revision",
)
)
}
can_create = can_request_actor_create_investigation(request)
items: list[dict[str, str]] = []
items: list[dict[str, Any]] = []
for source in resolved_sources:
if source is None:
items.append({"status": "unavailable"})
Expand All @@ -110,7 +132,14 @@ def post(self, request: Request, organization: Organization) -> Response:
) or existing_by_legacy_source_key.get(investigation_legacy_source_key(source.source))
if investigation is not None:
if investigation.id in viewable_ids:
items.append({"status": "view", "investigationId": str(investigation.id)})
item: dict[str, Any] = {
"status": "view",
"investigationId": str(investigation.id),
}
orchestration = orchestration_by_investigation.get(investigation.id)
if orchestration is not None:
item["orchestration"] = orchestration
items.append(item)
else:
items.append({"status": "unavailable"})
elif can_create:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@
from sentry.investigations.endpoints.base import (
OrganizationInvestigationEndpoint,
service_error,
user_id,
)
from sentry.investigations.endpoints.serializers import InvestigationDetailsSerializer
from sentry.investigations.endpoints.validators import (
InvestigationDeleteValidator,
InvestigationUpdateValidator,
)
from sentry.investigations.models import Investigation, InvestigationStatus
from sentry.investigations.services import archive_investigation, update_investigation
from sentry.investigations.services import (
archive_investigation_with_orchestration,
update_investigation_with_orchestration,
)
from sentry.models.organization import Organization


Expand Down Expand Up @@ -76,8 +80,10 @@ def put(
status=status.HTTP_400_BAD_REQUEST,
)
try:
archived = archive_investigation(
investigation=investigation, expected_version=expected_version
archived = archive_investigation_with_orchestration(
investigation=investigation,
expected_version=expected_version,
actor_id=user_id(request),
)
except Exception as error:
response = service_error(error)
Expand All @@ -92,7 +98,7 @@ def put(
)
)
try:
updated = update_investigation(
updated = update_investigation_with_orchestration(
investigation=investigation,
expected_version=expected_version,
fields=values,
Expand All @@ -118,9 +124,10 @@ def delete(
if not validator.is_valid():
return Response(validator.errors, status=status.HTTP_400_BAD_REQUEST)
try:
archive_investigation(
archive_investigation_with_orchestration(
investigation=investigation,
expected_version=validator.validated_data["investigation_version"],
actor_id=user_id(request),
)
except Exception as error:
response = service_error(error)
Expand Down
Loading
Loading