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.

Flag stale discoveries (pre-engine-version) for re-run in the panel

rcourtmanc4523aaf11cd
diff --git a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
index 24566653e7..515e768170 100644
--- a/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
+++ b/frontend-modern/src/components/Discovery/DiscoveryTab.tsx
@@ -35,6 +35,11 @@ import { useDiscoveryTabState } from './useDiscoveryTabState';
import { orderFactsByActionability } from './factOrdering';
import { deriveCliCommand } from './cliCommand';
+// Keep in sync with backend servicediscovery.DiscoveryEngineVersion. A discovery
+// with a lower (or absent) version predates the current discovery engine, so its
+// data is stale even if still within the time-based freshness window.
+const CURRENT_DISCOVERY_ENGINE_VERSION = 1;
+
interface DiscoveryTabProps {
resourceType: ResourceType;
agentId?: string;
@@ -160,6 +165,14 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
if (!current) return null;
return deriveCliCommand(props.resourceType, current.resource_id, current.cli_access);
});
+ // Stale when produced by an engine older than the current one — the time-based
+ // freshness window can still call it "fresh" even though re-running would yield
+ // materially better data.
+ const isStaleDiscovery = createMemo(() => {
+ const current = discovery();
+ if (!current) return false;
+ return (current.discovery_engine_version ?? 0) < CURRENT_DISCOVERY_ENGINE_VERSION;
+ });
const commandSettingsTarget = getDiscoveryCommandSettingsTarget();
const apiAccessSettingsTarget = getDiscoveryApiAccessSettingsTarget();
const showManualRunAction = () => props.showManualRunAction === true;
@@ -720,6 +733,17 @@ export const DiscoveryTab: Component<DiscoveryTabProps> = (props) => {
<Show when={validDiscovery()}>
{(d) => (
<div class="space-y-4">
+ <Show when={isStaleDiscovery()}>
+ <div class="rounded border border-amber-200 bg-amber-50/80 p-3 shadow-sm dark:border-amber-800/50 dark:bg-amber-900/20">
+ <div class="flex items-start gap-2">
+ <TriangleAlertIcon class="mt-0.5 h-4 w-4 flex-shrink-0 text-amber-600 dark:text-amber-400" />
+ <p class="text-xs text-amber-800 dark:text-amber-200">
+ This was discovered by an earlier version of Pulse. Re-run discovery for
+ improved identification and access details.
+ </p>
+ </div>
+ </div>
+ </Show>
{/* Service Header */}
<div class="rounded border border-border bg-surface p-3 shadow-sm">
<div class="flex items-start justify-between">
diff --git a/frontend-modern/src/types/discovery.ts b/frontend-modern/src/types/discovery.ts
index 4dbec0afec..3659d54daa 100644
--- a/frontend-modern/src/types/discovery.ts
+++ b/frontend-modern/src/types/discovery.ts
@@ -90,6 +90,7 @@ export interface ResourceDiscovery {
fingerprint?: string; // Hash when discovery was done
fingerprinted_at?: string; // When fingerprint was captured
fingerprint_schema_version?: number; // Schema version when fingerprint was captured
+ discovery_engine_version?: number; // Engine version that produced this result; absent/old => stale, re-run for better results
// Auto-suggested web interface URL
suggested_url?: string;
suggested_url_source_code?: string;
diff --git a/internal/servicediscovery/service.go b/internal/servicediscovery/service.go
index 3c26e12fb4..e0491396cb 100644
--- a/internal/servicediscovery/service.go
+++ b/internal/servicediscovery/service.go
@@ -1589,25 +1589,26 @@ func (s *Service) analyzeDockerContainer(ctx context.Context, analyzer AIAnalyze
}
return &ResourceDiscovery{
- ID: MakeResourceID(ResourceTypeDocker, host.AgentID, c.Name),
- ResourceType: ResourceTypeDocker,
- ResourceID: c.Name,
- TargetID: host.AgentID,
- Hostname: host.Hostname,
- ServiceType: result.ServiceType,
- ServiceName: result.ServiceName,
- ServiceVersion: result.ServiceVersion,
- Category: result.Category,
- CLIAccess: cliAccess,
- Facts: result.Facts,
- ConfigPaths: result.ConfigPaths,
- DataPaths: result.DataPaths,
- LogPaths: result.LogPaths,
- Ports: ports,
- Confidence: result.Confidence,
- AIReasoning: result.Reasoning,
- DiscoveredAt: time.Now(),
- UpdatedAt: time.Now(),
+ ID: MakeResourceID(ResourceTypeDocker, host.AgentID, c.Name),
+ ResourceType: ResourceTypeDocker,
+ ResourceID: c.Name,
+ TargetID: host.AgentID,
+ Hostname: host.Hostname,
+ ServiceType: result.ServiceType,
+ ServiceName: result.ServiceName,
+ ServiceVersion: result.ServiceVersion,
+ Category: result.Category,
+ CLIAccess: cliAccess,
+ DiscoveryEngineVersion: DiscoveryEngineVersion,
+ Facts: result.Facts,
+ ConfigPaths: result.ConfigPaths,
+ DataPaths: result.DataPaths,
+ LogPaths: result.LogPaths,
+ Ports: ports,
+ Confidence: result.Confidence,
+ AIReasoning: result.Reasoning,
+ DiscoveredAt: time.Now(),
+ UpdatedAt: time.Now(),
}
}
@@ -1859,27 +1860,28 @@ func (s *Service) DiscoverResource(ctx context.Context, req DiscoveryRequest) (*
// Build discovery result
discovery := &ResourceDiscovery{
- ID: resourceID,
- ResourceType: req.ResourceType,
- ResourceID: req.ResourceID,
- TargetID: req.TargetID,
- AgentID: agentID,
- Hostname: hostname,
- ServiceType: result.ServiceType,
- ServiceName: result.ServiceName,
- ServiceVersion: result.ServiceVersion,
- Category: result.Category,
- CLIAccess: s.formatCLIAccess(req.ResourceType, req.ResourceID, result.CLIAccess),
- CLIAccessVersion: CLIAccessVersion,
- Facts: result.Facts,
- ConfigPaths: result.ConfigPaths,
- DataPaths: result.DataPaths,
- LogPaths: result.LogPaths,
- Ports: result.Ports,
- Confidence: result.Confidence,
- AIReasoning: result.Reasoning,
- DiscoveredAt: time.Now(),
- UpdatedAt: time.Now(),
+ ID: resourceID,
+ ResourceType: req.ResourceType,
+ ResourceID: req.ResourceID,
+ TargetID: req.TargetID,
+ AgentID: agentID,
+ Hostname: hostname,
+ ServiceType: result.ServiceType,
+ ServiceName: result.ServiceName,
+ ServiceVersion: result.ServiceVersion,
+ Category: result.Category,
+ CLIAccess: s.formatCLIAccess(req.ResourceType, req.ResourceID, result.CLIAccess),
+ CLIAccessVersion: CLIAccessVersion,
+ DiscoveryEngineVersion: DiscoveryEngineVersion,
+ Facts: result.Facts,
+ ConfigPaths: result.ConfigPaths,
+ DataPaths: result.DataPaths,
+ LogPaths: result.LogPaths,
+ Ports: result.Ports,
+ Confidence: result.Confidence,
+ AIReasoning: result.Reasoning,
+ DiscoveredAt: time.Now(),
+ UpdatedAt: time.Now(),
}
// Store fingerprint with discovery
diff --git a/internal/servicediscovery/service_test.go b/internal/servicediscovery/service_test.go
index b9bd7739b4..3f32a5cc57 100644
--- a/internal/servicediscovery/service_test.go
+++ b/internal/servicediscovery/service_test.go
@@ -2112,6 +2112,11 @@ func TestService_RunManualDiscoveryRefreshRepairsFreshUnknownKnownService(t *tes
if discovery.SuggestedURL != "http://esphome:6052" {
t.Fatalf("expected stored ESPHome URL, got %q", discovery.SuggestedURL)
}
+ // A freshly produced discovery carries the current engine version so the panel
+ // can flag pre-upgrade (stale) data even within the time-based freshness window.
+ if discovery.DiscoveryEngineVersion != DiscoveryEngineVersion {
+ t.Fatalf("expected engine version %d stamped, got %d", DiscoveryEngineVersion, discovery.DiscoveryEngineVersion)
+ }
}
func TestService_DiscoverResource_URLSuggestionSource_Primary(t *testing.T) {
diff --git a/internal/servicediscovery/types.go b/internal/servicediscovery/types.go
index b0def7d691..a7d91db061 100644
--- a/internal/servicediscovery/types.go
+++ b/internal/servicediscovery/types.go
@@ -159,6 +159,7 @@ type ResourceDiscovery struct {
FingerprintedAt time.Time `json:"fingerprinted_at,omitempty"` // When fingerprint was captured
FingerprintSchemaVersion int `json:"fingerprint_schema_version,omitempty"` // Schema version when fingerprint was captured
CLIAccessVersion int `json:"cli_access_version,omitempty"` // Version of CLI access pattern format
+ DiscoveryEngineVersion int `json:"discovery_engine_version,omitempty"` // Discovery engine version that produced this result
// Raw data for debugging/re-analysis
RawCommandOutput map[string]string `json:"raw_command_output,omitempty"`
@@ -408,6 +409,13 @@ const FingerprintSchemaVersion = 3 // v3: Removed IP addresses (DHCP churn cause
// to use the new instructional format.
const CLIAccessVersion = 2 // v2: Changed from shell commands to pulse_control instructions
+// DiscoveryEngineVersion is incremented when the discovery engine's logic
+// changes enough that older cached results are worth re-running. Unlike
+// CLIAccessVersion it is NOT auto-upgraded on read — a stale value means the
+// discovery genuinely predates the current engine, so the panel can flag it for
+// a refresh. Bump this when identification/scan behavior changes materially.
+const DiscoveryEngineVersion = 1 // v1: surface fast-path + distinctive-port + nested-container access topology
+
type ContainerFingerprint struct {
ResourceID string `json:"resource_id"`
TargetID string `json:"target_id"`