mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-04-29 03:50:18 +00:00
When PVE backup polling detects permission errors (403/401/permission denied), track them per instance and surface them via the scheduler health endpoint. The Backups page now fetches instance warnings and displays a banner when backup permission issues are detected, telling users exactly how to fix the problem. Related to #1139
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
import { createSignal, createEffect, onCleanup } from 'solid-js';
|
|
|
|
interface InstanceHealth {
|
|
key: string;
|
|
type: string;
|
|
displayName: string;
|
|
instance: string;
|
|
warnings?: string[];
|
|
}
|
|
|
|
interface SchedulerHealth {
|
|
instances: InstanceHealth[];
|
|
}
|
|
|
|
/**
|
|
* Hook to fetch instance warnings from the scheduler health endpoint.
|
|
* Returns warnings for PVE instances (e.g., backup permission issues).
|
|
*/
|
|
export function useInstanceWarnings() {
|
|
const [warnings, setWarnings] = createSignal<Map<string, string[]>>(new Map());
|
|
const [loading, setLoading] = createSignal(true);
|
|
const [error, setError] = createSignal<string | null>(null);
|
|
|
|
const fetchWarnings = async () => {
|
|
try {
|
|
const response = await fetch('/api/monitoring/scheduler/health');
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP ${response.status}`);
|
|
}
|
|
const data: SchedulerHealth = await response.json();
|
|
|
|
const warningMap = new Map<string, string[]>();
|
|
for (const instance of data.instances || []) {
|
|
if (instance.warnings && instance.warnings.length > 0) {
|
|
warningMap.set(instance.instance, instance.warnings);
|
|
}
|
|
}
|
|
setWarnings(warningMap);
|
|
setError(null);
|
|
} catch (err) {
|
|
setError(err instanceof Error ? err.message : 'Failed to fetch warnings');
|
|
} finally {
|
|
setLoading(false);
|
|
}
|
|
};
|
|
|
|
createEffect(() => {
|
|
fetchWarnings();
|
|
// Refresh every 60 seconds
|
|
const interval = setInterval(fetchWarnings, 60000);
|
|
onCleanup(() => clearInterval(interval));
|
|
});
|
|
|
|
return {
|
|
warnings,
|
|
loading,
|
|
error,
|
|
refetch: fetchWarnings,
|
|
};
|
|
}
|