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.

Add Docker host web interface access (#1276)

[email protected]101735588cdd
diff --git a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
index 696243d83b..8b3c7ab74e 100644
--- a/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
+++ b/docs/release-control/v6/internal/subsystems/agent-lifecycle.md
@@ -3889,6 +3889,11 @@ That same node setup owner also includes
`frontend-modern/src/utils/nodeModalPresentation.ts`, which now owns the
canonical node-type defaults, endpoint/auth placeholders, monitoring coverage
copy, and test-result styling for PVE, PBS, and PMG setup.
+For PBS connections, the monitoring section also owns the datastore collection
+scope editor beside the datastore and backup monitoring toggles. It must
+round-trip the stored `excludeDatastores` list, accept comma-separated exact or
+wildcard patterns, and submit the canonical collection without changing agent
+identity, credentials, registration, or connection lifecycle.
That presentation layer remains presentation-only for those API-managed
Proxmox, PBS, and PMG connections. Lifecycle guidance in that settings surface
may explain monitored-system grouping, but monitored-system volume caps are
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index bdc072db27..c12d0670aa 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -7254,6 +7254,12 @@ frontend consumers may normalize endpoint fields, but they must not fork the
canonical collection-shape guard or reintroduce legacy `alert_identifier`
field access once camelCase `alertIdentifier` has been promoted by the shared
response helpers.
+For PBS nodes, `GET /api/config/nodes` and `PUT /api/config/nodes/{id}` expose
+`excludeDatastores` as a string collection. Omitting it from a partial update
+preserves the stored exclusion list, while an explicit empty collection clears
+it. The PBS node modal hydrates the collection into its comma-separated editor,
+parses the edited patterns back into the canonical array payload, and must not
+treat exclusions as client-only display state.
The node update payload on `PUT /api/config/nodes/{id}` now also carries an
optional write-only `clusterEndpointOverrides` collection of
`{nodeName, ipOverride}` entries handled by
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 301e25f2c6..6c26b144ca 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -3421,6 +3421,14 @@ warning rather than disappearing or becoming executable. Runtime/platform
tables must not add separate `Web` columns, page-local external-link anchors,
linked resource names, or duplicated new-tab safety handling for that launch
affordance.
+Docker host rows follow the same primitive-owned contract end to end.
+`DockerHostsTable.tsx` composes `ResourceNameWithWebInterfaceLink` beside the
+inert host name, while the host drawer's Overview access surface embeds
+`WebInterfaceUrlField` with `metadataKind="docker-host"` and the stable host
+source id. The drawer must return saved URL changes to its owning table row so
+the adjacent launch control updates immediately; neither the table nor drawer
+may fork metadata transport, URL validation, or new-tab behavior into a
+Docker-local implementation.
Shared-template drift enforcement is registry-backed:
`frontend-modern/scripts/shared-template-registry.json` is the canonical list of
standardized repeated affordances, required consumers, and forbidden local
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 85f99f34a1..b3d91bc79b 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -82,6 +82,14 @@ full backup point batch per poll cycle. Complete authoritative enumerations
coalesce only within the same provider, ID-prefix, and instance scope; distinct
source scopes and non-reconciling event batches remain FIFO so bounding memory
does not discard independent recovery facts.
+PBS datastore exclusions are applied to the cheap datastore-name listing
+before any per-store RRD, status, garbage-collection, namespace, group, or
+backup request. Exact, prefix, suffix, and contains patterns use the canonical
+case-insensitive datastore matcher. An excluded datastore must be absent from
+the monitoring snapshot, storage projection, and backup enumeration, and the
+version-compatibility fallback must use the same pre-detail filter rather than
+reintroducing requests for excluded removable or intermittently offline
+stores.
PBS snapshot-to-guest attribution for VMIDs that exist on more than one PVE
location is evidence-driven, never guessed. When the direct PBS connection is
authoritative and pbs-type storage contents are dropped from the PVE backup
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 703f0b6492..1bac41867b 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -538,6 +538,12 @@ The same presentation contract applies to Docker/Podman hosts and containers,
standalone agents, PBS/PMG instances, Kubernetes clusters/nodes/workloads, and
card or mobile variants. An absent URL is honestly absent, while an invalid or
unsafe saved value remains visible as a non-interactive warning.
+Docker host URL metadata is keyed by the stable `Docker.HostSourceID`, with the
+registered host resource id as a compatibility fallback when source identity
+is unavailable. The Docker hosts table and drawer consume the same canonical
+`customUrl`: launch activation must not toggle or navigate the row, and a
+drawer save must update the current table projection immediately while the
+backend metadata projection remains authoritative on refresh.
Persisted workload URLs must also use the same stable identity in the workload
and infrastructure drawers. Docker app containers use
`app-container:<host>:name:<normalized-name>`; Kubernetes pods, Deployments,
diff --git a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
index a4ec77c7b4..d0c93a6bfd 100644
--- a/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
+++ b/frontend-modern/src/components/Settings/__tests__/settingsArchitecture.test.ts
@@ -71,6 +71,7 @@ import nodeModalSetupGuideSectionSource from '../NodeModalSetupGuideSection.tsx?
import nodeModalStatusFooterSource from '../NodeModalStatusFooter.tsx?raw';
import nodeModalModelSource from '../nodeModalModel.ts?raw';
import nodeModalStateSource from '../useNodeModalState.ts?raw';
+import nodeModalPresentationSource from '../../../utils/nodeModalPresentation.ts?raw';
import availabilityTargetSlotSource from '../ConnectionEditor/CredentialSlots/AvailabilityTargetSlot.tsx?raw';
import trueNASCredentialSlotSource from '../ConnectionEditor/CredentialSlots/TrueNASCredentialSlot.tsx?raw';
import vmwareCredentialSlotSource from '../ConnectionEditor/CredentialSlots/VMwareCredentialSlot.tsx?raw';
@@ -1482,6 +1483,12 @@ describe('settings architecture guardrails', () => {
expect(nodeCredentialSlotSource).toContain('<NodeModalAuthenticationSection');
expect(nodeCredentialSlotSource).toContain('<NodeModalMonitoringSection');
expect(nodeCredentialSlotSource).toContain('<NodeModalStatusFooter');
+ expect(nodeModalMonitoringSectionSource).toContain('Excluded datastores (optional)');
+ expect(nodeModalMonitoringSectionSource).toContain("state.updateField('excludeDatastores'");
+ expect(nodeModalStateSource).toContain(
+ "excludeDatastores: pbsConfig?.excludeDatastores?.join(', ') ?? ''",
+ );
+ expect(nodeModalPresentationSource).toContain('excludeDatastores: formData.excludeDatastores');
expect(nodeCredentialSlotSource).not.toContain('<Dialog');
expect(nodeCredentialSlotSource).toContain('buildNodeImportPlan');
expect(nodeCredentialSlotSource).toContain('MonitoredSystemLedgerAPI.preview');
diff --git a/frontend-modern/src/features/docker/DockerHostDrawer.tsx b/frontend-modern/src/features/docker/DockerHostDrawer.tsx
index 22fa9d55a6..039c38cf4b 100644
--- a/frontend-modern/src/features/docker/DockerHostDrawer.tsx
+++ b/frontend-modern/src/features/docker/DockerHostDrawer.tsx
@@ -24,6 +24,8 @@ import {
interface DockerHostDrawerProps {
host: Resource;
+ customUrl?: string;
+ onCustomUrlChange?: (url: string) => void;
}
type DockerHostDrawerTab = 'overview' | 'history' | 'discovery';
@@ -72,7 +74,11 @@ export const DockerHostDrawer: Component<DockerHostDrawerProps> = (props) => {
{/* Use CSS hidden instead of Show to avoid mount/unmount which causes scroll jumps.
overflow-anchor: none prevents browser scroll anchoring from jumping when display toggles. */}
<div class={activeTab() === 'overview' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
- <DockerHostDrawerOverview host={props.host} />
+ <DockerHostDrawerOverview
+ host={props.host}
+ customUrl={props.customUrl}
+ onCustomUrlChange={props.onCustomUrlChange}
+ />
</div>
<div class={activeTab() === 'history' ? '' : 'hidden'} style={{ 'overflow-anchor': 'none' }}>
diff --git a/frontend-modern/src/features/docker/DockerHostDrawerOverview.tsx b/frontend-modern/src/features/docker/DockerHostDrawerOverview.tsx
index 7417da08f0..7c3cb3ee9f 100644
--- a/frontend-modern/src/features/docker/DockerHostDrawerOverview.tsx
+++ b/frontend-modern/src/features/docker/DockerHostDrawerOverview.tsx
@@ -7,6 +7,7 @@ import {
} from '@/components/Workloads/DrawerDiskListCard';
import { AvailabilityProbeStatusCards } from '@/components/Infrastructure/AvailabilityProbeStatusCard';
import { InfoCardFrame } from '@/components/shared/InfoCardFrame';
+import { WebInterfaceUrlField } from '@/components/shared/WebInterfaceUrlField';
import { useResourceDetailDrawerDockerActionsState } from '@/components/Infrastructure/useResourceDetailDrawerDockerActionsState';
import { hostOverrideIdCandidates } from '@/features/alerts/alertOverridesModel';
import { areSystemSettingsLoaded, shouldHideDockerUpdateActions } from '@/stores/systemSettings';
@@ -25,6 +26,8 @@ import { hasDockerSwarmEvidence } from './dockerPageModel';
interface DockerHostDrawerOverviewProps {
host: Resource;
+ customUrl?: string;
+ onCustomUrlChange?: (url: string) => void;
}
interface DockerOverviewRow {
@@ -116,6 +119,7 @@ export function DockerHostDrawerOverview(props: DockerHostDrawerOverviewProps) {
const docker = () => props.host.docker;
const agent = () => props.host.agent;
const linkedAgentId = () => cleanText(agent()?.agentId);
+ const metadataId = () => cleanText(docker()?.hostSourceId) || cleanText(props.host.id);
const temperatureThresholds = createMemo(() =>
alertsActivation.getMetricThresholds(
'node',
@@ -453,6 +457,14 @@ export function DockerHostDrawerOverview(props: DockerHostDrawerOverviewProps) {
<DrawerDiskListCard disks={perDiskItems()} testId="docker-host-drawer-disks" />
</Show>
<DetailCard title="Telemetry" rows={telemetryRows()} />
+ <WebInterfaceUrlField
+ metadataKind="docker-host"
+ metadataId={metadataId()}
+ targetLabel={cleanText(props.host.name) || 'Docker host'}
+ title="Access"
+ customUrl={props.customUrl ?? props.host.customUrl ?? ''}
+ onCustomUrlChange={props.onCustomUrlChange}
+ />
</div>
);
}
diff --git a/frontend-modern/src/features/docker/DockerHostsTable.tsx b/frontend-modern/src/features/docker/DockerHostsTable.tsx
index 1d7ddf1610..6bd82369f9 100644
--- a/frontend-modern/src/features/docker/DockerHostsTable.tsx
+++ b/frontend-modern/src/features/docker/DockerHostsTable.tsx
@@ -1,5 +1,6 @@
import { For, Show, createMemo, createSignal, type Component, type JSX } from 'solid-js';
import { InlineDetailTableRow } from '@/components/shared/InlineDetailTableRow';
+import { ResourceNameWithWebInterfaceLink } from '@/components/shared/WebInterfaceLink';
import { StatusDot } from '@/components/shared/StatusDot';
import { DockerHostDrawer } from './DockerHostDrawer';
import { ResponsiveMetricCell } from '@/components/shared/responsive';
@@ -328,6 +329,7 @@ export const DockerHostsTable: Component<{
{(host) => {
const docker = () => dockerHostMeta(host);
const name = () => asTrimmedString(host.name) || host.id;
+ const [customUrl, setCustomUrl] = createSignal(asTrimmedString(host.customUrl));
const systemBadge = () => getDockerHostSystemBadge(host);
const version = () => asTrimmedString(docker()?.runtimeVersion) || '—';
const containerCount = () => docker()?.containerCount ?? 0;
@@ -407,9 +409,11 @@ export const DockerHostsTable: Component<{
title={host.status || 'unknown'}
ariaHidden
/>
- <span class="truncate font-semibold text-base-content" title={name()}>
- {name()}
- </span>
+ <ResourceNameWithWebInterfaceLink
+ name={name()}
+ url={customUrl()}
+ nameClass="truncate font-semibold text-base-content"
+ />
</div>
<Show when={systemBadge()}>
{(badge) => (
@@ -516,7 +520,11 @@ export const DockerHostsTable: Component<{
colspan={drawerColspan()}
data-inline-docker-host-detail-for={host.id}
>
- <DockerHostDrawer host={host} />
+ <DockerHostDrawer
+ host={host}
+ customUrl={customUrl()}
+ onCustomUrlChange={setCustomUrl}
+ />
</InlineDetailTableRow>
</Show>
</>
diff --git a/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsx b/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsx
index 94c3328b77..f76f8a85d7 100644
--- a/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsx
+++ b/frontend-modern/src/features/docker/__tests__/DockerHostsTable.test.tsx
@@ -17,6 +17,9 @@ const getMetricThresholdsMock = vi.hoisted(() =>
metric === 'memory' ? { warning: 90, critical: 95 } : { warning: 80, critical: 85 },
),
);
+const updateDockerHostMetadataMock = vi.hoisted(() =>
+ vi.fn(async (_runtimeId: string, metadata: { customUrl?: string }) => metadata),
+);
vi.mock('@/components/shared/responsive', () => ({
ResponsiveMetricCell: (props: {
@@ -43,6 +46,12 @@ vi.mock('@/stores/alertsActivation', () => ({
getMetricThresholds: getMetricThresholdsMock,
}),
}));
+vi.mock('@/api/dockerHostMetadata', () => ({
+ DockerHostMetadataAPI: {
+ getMetadata: vi.fn(async () => ({})),
+ updateMetadata: updateDockerHostMetadataMock,
+ },
+}));
vi.mock('@/components/Workloads/StackedMemoryBar', () => ({
StackedMemoryBar: (props: {
@@ -153,10 +162,7 @@ describe('DockerHostsTable', () => {
/>
));
- expect(screen.getByTestId('responsive-cpu-metric')).toHaveAttribute(
- 'data-thresholds',
- '80/85',
- );
+ expect(screen.getByTestId('responsive-cpu-metric')).toHaveAttribute('data-thresholds', '80/85');
expect(screen.getByTestId('stacked-memory-bar')).toHaveAttribute('data-thresholds', '90/95');
expect(screen.getByTestId('stacked-disk-bar')).toHaveAttribute('data-thresholds', '80/85');
expect(getMetricThresholdsMock).toHaveBeenCalledWith(
@@ -192,6 +198,68 @@ describe('DockerHostsTable', () => {
expect(screen.getByRole('tab', { name: 'History' })).toHaveAttribute('type', 'button');
});
+ it('opens a saved Docker host web interface without toggling the row', () => {
+ render(() => (
+ <DockerHostsTable
+ resources={[
+ makeDockerHost({
+ customUrl: 'https://docker-01.example:9443',
+ }),
+ ]}
+ emptyIcon={<span />}
+ emptyTitle="No Docker hosts"
+ emptyDescription="No hosts"
+ showToolbar={false}
+ />
+ ));
+
+ const row = screen.getByText('docker-01').closest('tr')!;
+ const link = screen.getByRole('link', { name: 'Open web interface for docker-01' });
+ expect(link).toHaveAttribute('href', 'https://docker-01.example:9443');
+
+ fireEvent.click(link);
+
+ expect(row).toHaveAttribute('aria-expanded', 'false');
+ expect(screen.queryByTestId('docker-host-drawer')).not.toBeInTheDocument();
+ });
+
+ it('edits the Docker host access URL in the drawer and updates the row link', async () => {
+ render(() => (
+ <DockerHostsTable
+ resources={[
+ makeDockerHost({
+ docker: {
+ runtimeVersion: '27.5.1',
+ containerCount: 12,
+ hostSourceId: 'runtime-stable-id',
+ } as NonNullable<Resource['docker']>,
+ }),
+ ]}
+ emptyIcon={<span />}
+ emptyTitle="No Docker hosts"
+ emptyDescription="No hosts"
+ showToolbar={false}
+ />
+ ));
+
+ fireEvent.click(screen.getByText('docker-01').closest('tr')!);
+
+ const drawer = screen.getByTestId('docker-host-drawer');
+ expect(within(drawer).getByText('Access')).toBeInTheDocument();
+ const input = within(drawer).getByRole('textbox');
+ fireEvent.input(input, { target: { value: 'https://portainer.example:9443' } });
+ fireEvent.click(within(drawer).getByRole('button', { name: 'Save' }));
+
+ await vi.waitFor(() => {
+ expect(updateDockerHostMetadataMock).toHaveBeenCalledWith('runtime-stable-id', {
+ customUrl: 'https://portainer.example:9443',
+ });
+ expect(
+ screen.getByRole('link', { name: 'Open web interface for docker-01' }),
+ ).toHaveAttribute('href', 'https://portainer.example:9443');
+ });
+ });
+
it('keeps an attached availability check visible in the host detail', () => {
render(() => (
<DockerHostsTable
diff --git a/internal/monitoring/monitor_pbs_coverage_test.go b/internal/monitoring/monitor_pbs_coverage_test.go
index 453c585f64..8795498d1e 100644
--- a/internal/monitoring/monitor_pbs_coverage_test.go
+++ b/internal/monitoring/monitor_pbs_coverage_test.go
@@ -7,6 +7,7 @@ import (
"net/http/httptest"
"os"
"strings"
+ "sync"
"testing"
"time"
@@ -15,6 +16,94 @@ import (
"github.com/rcourtman/pulse-go-rewrite/pkg/pbs"
)
+func TestPollPBSInstanceDoesNotQueryExcludedDatastoreDetails(t *testing.T) {
+ var mu sync.Mutex
+ var requestedPaths []string
+
+ server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ mu.Lock()
+ requestedPaths = append(requestedPaths, r.URL.Path)
+ mu.Unlock()
+
+ switch r.URL.Path {
+ case "/api2/json/version":
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "data": map[string]any{"version": "3.4"},
+ })
+ case "/api2/json/nodes/localhost/status":
+ _ = json.NewEncoder(w).Encode(map[string]any{"data": map[string]any{}})
+ case "/api2/json/admin/datastore":
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "data": []map[string]string{
+ {"store": "internal"},
+ {"store": "exthdd1500gb"},
+ },
+ })
+ case "/api2/json/admin/datastore/internal/rrd":
+ _ = json.NewEncoder(w).Encode(map[string]any{"data": []any{}})
+ case "/api2/json/admin/datastore/internal/status":
+ _ = json.NewEncoder(w).Encode(map[string]any{
+ "data": map[string]any{
+ "total": 100.0,
+ "used": 25.0,
+ "avail": 75.0,
+ },
+ })
+ case "/api2/json/admin/datastore/internal/gc":
+ _ = json.NewEncoder(w).Encode(map[string]any{"data": map[string]any{}})
+ case "/api2/json/admin/datastore/internal/namespace":
+ _ = json.NewEncoder(w).Encode(map[string]any{"data": []any{}})
+ default:
+ http.Error(w, "unexpected request", http.StatusInternalServerError)
+ }
+ }))
+ defer server.Close()
+
+ client, err := pbs.NewClient(pbs.ClientConfig{
+ Host: server.URL,
+ TokenName: "root@pam!pulse-token",
+ TokenValue: "secret",
+ })
+ if err != nil {
+ t.Fatalf("NewClient failed: %v", err)
+ }
+
+ monitor := &Monitor{
+ config: &config.Config{
+ PBSInstances: []config.PBSInstance{{
+ Name: "pbs-excludes",
+ Host: server.URL,
+ MonitorDatastores: true,
+ ExcludeDatastores: []string{"ext*"},
+ }},
+ },
+ state: models.NewState(),
+ authFailures: make(map[string]int),
+ lastAuthAttempt: make(map[string]time.Time),
+ pollStatusMap: make(map[string]*pollStatus),
+ circuitBreakers: make(map[string]*circuitBreaker),
+ }
+
+ monitor.pollPBSInstance(context.Background(), "pbs-excludes", client)
+
+ snapshot := monitor.state.GetSnapshot()
+ if len(snapshot.PBSInstances) != 1 {
+ t.Fatalf("PBS instances = %+v, want one", snapshot.PBSInstances)
+ }
+ datastores := snapshot.PBSInstances[0].Datastores
+ if len(datastores) != 1 || datastores[0].Name != "internal" {
+ t.Fatalf("datastores = %+v, want only internal", datastores)
+ }
+
+ mu.Lock()
+ defer mu.Unlock()
+ for _, path := range requestedPaths {
+ if strings.Contains(path, "exthdd1500gb") {
+ t.Fatalf("excluded datastore received a detail request: %s", path)
+ }
+ }
+}
+
func TestMonitor_PollPBSInstance_AuthFailure(t *testing.T) {
// Setup mock server that returns 401
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
diff --git a/internal/monitoring/monitor_pbs_datastore_exclude_test.go b/internal/monitoring/monitor_pbs_datastore_exclude_test.go
deleted file mode 100644
index cff72cb161..0000000000
--- a/internal/monitoring/monitor_pbs_datastore_exclude_test.go
+++ /dev/null
@@ -1,104 +0,0 @@
-package monitoring
-
-import (
- "context"
- "encoding/json"
- "net/http"
- "net/http/httptest"
- "strings"
- "sync"
- "testing"
- "time"
-
- "github.com/rcourtman/pulse-go-rewrite/internal/config"
- "github.com/rcourtman/pulse-go-rewrite/internal/models"
- "github.com/rcourtman/pulse-go-rewrite/pkg/pbs"
-)
-
-func TestPollPBSInstanceDoesNotQueryExcludedDatastoreDetails(t *testing.T) {
- var mu sync.Mutex
- var requestedPaths []string
-
- server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- mu.Lock()
- requestedPaths = append(requestedPaths, r.URL.Path)
- mu.Unlock()
-
- switch r.URL.Path {
- case "/api2/json/version":
- _ = json.NewEncoder(w).Encode(map[string]any{
- "data": map[string]any{"version": "3.4"},
- })
- case "/api2/json/nodes/localhost/status":
- _ = json.NewEncoder(w).Encode(map[string]any{"data": map[string]any{}})
- case "/api2/json/admin/datastore":
- _ = json.NewEncoder(w).Encode(map[string]any{
- "data": []map[string]string{
- {"store": "internal"},
- {"store": "exthdd1500gb"},
- },
- })
- case "/api2/json/admin/datastore/internal/rrd":
- _ = json.NewEncoder(w).Encode(map[string]any{"data": []any{}})
- case "/api2/json/admin/datastore/internal/status":
- _ = json.NewEncoder(w).Encode(map[string]any{
- "data": map[string]any{
- "total": 100.0,
- "used": 25.0,
- "avail": 75.0,
- },
- })
- case "/api2/json/admin/datastore/internal/gc":
- _ = json.NewEncoder(w).Encode(map[string]any{"data": map[string]any{}})
- case "/api2/json/admin/datastore/internal/namespace":
- _ = json.NewEncoder(w).Encode(map[string]any{"data": []any{}})
- default:
- http.Error(w, "unexpected request", http.StatusInternalServerError)
- }
- }))
- defer server.Close()
-
- client, err := pbs.NewClient(pbs.ClientConfig{
- Host: server.URL,
- TokenName: "root@pam!pulse-token",
- TokenValue: "secret",
- })
- if err != nil {
- t.Fatalf("NewClient failed: %v", err)
- }
-
- monitor := &Monitor{
- config: &config.Config{
- PBSInstances: []config.PBSInstance{{
- Name: "pbs-excludes",
- Host: server.URL,
- MonitorDatastores: true,
- ExcludeDatastores: []string{"ext*"},
- }},
- },
- state: models.NewState(),
- authFailures: make(map[string]int),
- lastAuthAttempt: make(map[string]time.Time),
- pollStatusMap: make(map[string]*pollStatus),
- circuitBreakers: make(map[string]*circuitBreaker),
- }
-
- monitor.pollPBSInstance(context.Background(), "pbs-excludes", client)
-
- snapshot := monitor.state.GetSnapshot()
- if len(snapshot.PBSInstances) != 1 {
- t.Fatalf("PBS instances = %+v, want one", snapshot.PBSInstances)
- }
- datastores := snapshot.PBSInstances[0].Datastores
- if len(datastores) != 1 || datastores[0].Name != "internal" {
- t.Fatalf("datastores = %+v, want only internal", datastores)
- }
-
- mu.Lock()
- defer mu.Unlock()
- for _, path := range requestedPaths {
- if strings.Contains(path, "exthdd1500gb") {
- t.Fatalf("excluded datastore received a detail request: %s", path)
- }
- }
-}