Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Fix action execution dry-run guard and verification bridge

rcourtmancfef1b67aea5
diff --git a/internal/api/actions.go b/internal/api/actions.go
index 45877e9980..2b759cb164 100644
--- a/internal/api/actions.go
+++ b/internal/api/actions.go
@@ -346,16 +346,15 @@ func (h *ResourceHandlers) HandleExecuteAction(w http.ResponseWriter, r *http.Re
}
actor := actionDecisionActor(h, r)
- if h.actionExecutor == nil {
- writeJSONError(w, http.StatusNotImplemented, "action_executor_unavailable", "No action executor is configured for this API instance")
- return
- }
-
now := time.Now().UTC()
if err := unified.ValidateActionExecutionStart(record, now); err != nil {
writeActionExecutionApplyError(w, err)
return
}
+ if h.actionExecutor == nil {
+ writeJSONError(w, http.StatusNotImplemented, "action_executor_unavailable", "No action executor is configured for this API instance")
+ return
+ }
if err := h.validateActionPlanFresh(orgID, record); err != nil {
if errors.Is(err, unified.ErrActionPlanDrift) {
if failed, persistErr := recordRefusedActionExecution(store, record, actor, now, err); persistErr == nil {
diff --git a/internal/api/router.go b/internal/api/router.go
index 785103b1c6..9b6aee422d 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -2613,7 +2613,7 @@ func (r *Router) wireAIChatDependenciesForService(ctx context.Context, service A
if executor := chatService.GetExecutor(); executor != nil {
broadcaster := r.agentEventBroadcaster
executor.SetOnActionCompleted(func(record unifiedresources.ActionAuditRecord) {
- broadcaster.PublishActionCompletedRecord(record)
+ r.publishActionCompletedAgentEvent(broadcaster, record)
})
}
}
@@ -2968,6 +2968,44 @@ func convertIncidentWindow(window *metrics.IncidentWindow) *tools.IncidentWindow
}
}
+func (r *Router) publishActionCompletedAgentEvent(broadcaster *AgentEventBroadcaster, record unifiedresources.ActionAuditRecord) {
+ if broadcaster == nil {
+ return
+ }
+ payload, ok := projectAgentActionCompletedPayload(record)
+ if !ok {
+ broadcaster.PublishActionCompletedRecord(record)
+ return
+ }
+ broadcaster.PublishActionCompleted(payload)
+}
+
+func projectAgentActionCompletedPayload(record unifiedresources.ActionAuditRecord) (AgentEventActionCompletedPayload, bool) {
+ if record.State != unifiedresources.ActionStateCompleted && record.State != unifiedresources.ActionStateFailed {
+ return AgentEventActionCompletedPayload{}, false
+ }
+
+ payload := AgentEventActionCompletedPayload{
+ ActionID: record.ID,
+ ResourceID: record.Request.ResourceID,
+ CapabilityName: record.Request.CapabilityName,
+ State: string(record.State),
+ RequestedBy: record.Request.RequestedBy,
+ CompletedAt: record.UpdatedAt,
+ }
+ if cmd, ok := record.Request.Params["command"].(string); ok {
+ payload.Command = cmd
+ }
+ if record.Result != nil {
+ payload.Success = record.Result.Success
+ payload.ErrorMessage = record.Result.ErrorMessage
+ if v := projectAgentResourceVerification(record.Result.Verification); v != nil {
+ payload.Verification = v
+ }
+ }
+ return payload, true
+}
+
// eventCorrelatorProviderWrapper adapts proxmox.EventCorrelator to tools.EventCorrelatorProvider.
type eventCorrelatorProviderWrapper struct {
correlator *proxmox.EventCorrelator