Files
Pulse/internal/unifiedresources/incident_actions.go
2026-03-30 19:45:29 +01:00

64 lines
2.8 KiB
Go

package unifiedresources
import "github.com/rcourtman/pulse-go-rewrite/internal/storagehealth"
const (
IncidentUrgencyNow = "now"
IncidentUrgencyToday = "today"
IncidentUrgencyPlan = "plan"
IncidentUrgencyMonitor = "monitor"
)
func IncidentActionForResource(resource *Resource, incident ResourceIncident, category string) (string, string) {
baseType := resourceBaseType(resource)
switch category {
case IncidentCategoryProtection:
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyNow, "Restore protection immediately and replace or recover the affected member"
}
return IncidentUrgencyToday, "Investigate degraded protection and schedule maintenance to restore redundancy"
case IncidentCategoryRebuild:
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyToday, "Investigate rebuild risk and avoid further changes until protection stabilizes"
}
return IncidentUrgencyMonitor, "Monitor rebuild progress and avoid risky storage changes until it completes"
case IncidentCategoryCapacity:
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyNow, "Free space or expand capacity immediately"
}
return IncidentUrgencyToday, "Plan cleanup or capacity expansion soon"
case IncidentCategoryRecoverability:
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyNow, "Restore backup target health immediately to protect recoverability"
}
return IncidentUrgencyToday, "Investigate backup target health and preserve backup coverage"
case IncidentCategoryDiskHealth:
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyNow, "Replace the affected disk and confirm storage protection"
}
return IncidentUrgencyToday, "Investigate disk health and schedule replacement if degradation continues"
case IncidentCategoryAvailability:
if baseType == ResourceTypeAgent || baseType == ResourceTypeVM {
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyNow, "Restore resource availability immediately"
}
return IncidentUrgencyToday, "Investigate degraded resource availability"
}
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyNow, "Restore storage availability immediately"
}
return IncidentUrgencyToday, "Investigate degraded storage availability"
default:
if baseType == ResourceTypeAgent || baseType == ResourceTypeVM {
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyToday, "Investigate resource health immediately"
}
return IncidentUrgencyPlan, "Review resource health and plan corrective action"
}
if incident.Severity == storagehealth.RiskCritical {
return IncidentUrgencyToday, "Investigate storage health immediately"
}
return IncidentUrgencyPlan, "Review storage health and plan corrective action"
}
}