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.

Degrade VMware optional enrichment reads

rcourtman7faf95986dd1
diff --git a/docs/release-control/v6/internal/subsystems/api-contracts.md b/docs/release-control/v6/internal/subsystems/api-contracts.md
index 5be63acabe..7853290d3b 100644
--- a/docs/release-control/v6/internal/subsystems/api-contracts.md
+++ b/docs/release-control/v6/internal/subsystems/api-contracts.md
@@ -707,7 +707,11 @@ implementation contract under `internal/api/vmware_handlers.go`,
stored connection shape plus canonical `poll` health and `observed`
contribution summary (`hosts`, `vms`, `datastores`, `viRelease`) so the shared
settings workspace can render VMware status without another provider-local
-inventory route. That `poll` payload is the canonical runtime contract:
+inventory route. When base inventory succeeds but optional signal or topology
+reads degrade, that same `observed` payload must carry the canonical
+partial-success shape (`degraded`, `issueCount`, summarized `issues`) instead
+of collapsing the whole connection to `poll.lastError` or pretending the
+refresh was fully healthy. That `poll` payload is the canonical runtime contract:
backend handlers must source it from the poller-owned per-connection summary,
saved row-level retests with no payload must refresh that same summary owner,
and edit-form overlay tests must preserve the stored summary until a real save
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index f89da312a1..01f217d99c 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -109,6 +109,13 @@ with no edit overlay must refresh that same summary owner, and
recomputing or shadowing it inside handler-local runtime state. Internal
sub-second test harness intervals must not leak `intervalSeconds: 0` onto that
operator-facing contract.
+That same summary owner also owns VMware partial-success classification.
+Optional VI JSON or Automation enrichment reads that fail after base
+host/VM/datastore inventory succeeds must not collapse the whole poll into a
+runtime failure. The client should preserve the usable base snapshot, record
+degraded enrichment issues on the snapshot, and let the poller publish those
+as `observed.degraded` plus summarized issue metadata instead of clearing the
+observed contribution or pretending the refresh was fully healthy.
That provider ownership now has a concrete phase-1 runtime seam:
`internal/monitoring/vmware_poller.go` must keep VMware inventory on the
shared supplemental-ingest path, declare `SourceVMware` as its owned source,
diff --git a/frontend-modern/src/api/__tests__/vmware.test.ts b/frontend-modern/src/api/__tests__/vmware.test.ts
index a8457539de..070d3d4aca 100644
--- a/frontend-modern/src/api/__tests__/vmware.test.ts
+++ b/frontend-modern/src/api/__tests__/vmware.test.ts
@@ -34,6 +34,16 @@ describe('VMwareAPI', () => {
vms: 42,
datastores: 6,
viRelease: ' 8.0.3 ',
+ degraded: true,
+ issueCount: 3,
+ issues: [
+ {
+ stage: ' signals ',
+ category: ' permission ',
+ message: ' VMware permissions are insufficient for host overall status ',
+ occurrences: 2,
+ },
+ ],
},
},
]);
@@ -61,6 +71,16 @@ describe('VMwareAPI', () => {
vms: 42,
datastores: 6,
viRelease: '8.0.3',
+ degraded: true,
+ issueCount: 3,
+ issues: [
+ {
+ stage: 'signals',
+ category: 'permission',
+ message: 'VMware permissions are insufficient for host overall status',
+ occurrences: 2,
+ },
+ ],
},
},
]);
diff --git a/frontend-modern/src/api/vmware.ts b/frontend-modern/src/api/vmware.ts
index 70bff23dd6..5e5c2d9be5 100644
--- a/frontend-modern/src/api/vmware.ts
+++ b/frontend-modern/src/api/vmware.ts
@@ -14,6 +14,7 @@ const REDACTED_SECRET = '********';
type RawVMwareConnection = Partial<VMwareConnection>;
type RawVMwareConnectionPollError = Partial<VMwareConnectionPollError>;
type RawVMwareConnectionPoll = Partial<VMwareConnectionPollStatus>;
+type RawVMwareConnectionObservedIssue = Partial<VMwareConnectionObservedIssue>;
type RawVMwareConnectionObservedSummary = Partial<VMwareConnectionObservedSummary>;
export interface VMwareConnectionPollError {
@@ -36,6 +37,16 @@ export interface VMwareConnectionObservedSummary {
vms: number;
datastores: number;
viRelease?: string;
+ degraded?: boolean;
+ issueCount?: number;
+ issues?: VMwareConnectionObservedIssue[];
+}
+
+export interface VMwareConnectionObservedIssue {
+ stage?: string;
+ category?: string;
+ message?: string;
+ occurrences?: number;
}
export interface VMwareConnection {
@@ -99,6 +110,14 @@ const normalizeVMwareConnectionObservedSummary = (
vms: finiteNumberOrUndefined(observed.vms) ?? 0,
datastores: finiteNumberOrUndefined(observed.datastores) ?? 0,
viRelease: optionalTrimmedString(observed.viRelease),
+ degraded: strictBoolean(observed.degraded),
+ issueCount: finiteNumberOrUndefined(observed.issueCount),
+ issues: arrayOrUndefined<RawVMwareConnectionObservedIssue>(observed.issues)?.map((issue) => ({
+ stage: optionalTrimmedString(issue.stage),
+ category: optionalTrimmedString(issue.category),
+ message: optionalTrimmedString(issue.message),
+ occurrences: finiteNumberOrUndefined(issue.occurrences),
+ })),
};
};
diff --git a/frontend-modern/src/components/Settings/VMwareSettingsPanel.tsx b/frontend-modern/src/components/Settings/VMwareSettingsPanel.tsx
index ecb053e40e..eda034521d 100644
--- a/frontend-modern/src/components/Settings/VMwareSettingsPanel.tsx
+++ b/frontend-modern/src/components/Settings/VMwareSettingsPanel.tsx
@@ -27,13 +27,25 @@ const dangerButtonClass =
const connectionMetaBadgeClass =
'inline-flex items-center rounded-full border border-border bg-surface px-2 py-0.5 text-xs font-medium text-muted';
+const getObservedIssueSummary = (connection: VMwareConnection): string | null => {
+ const observed = connection.observed;
+ const firstIssue = observed?.issues?.find((issue) => !!issue.message);
+ if (!firstIssue?.message) return null;
+ const issueCount = observed?.issueCount ?? observed?.issues?.length ?? 0;
+ if (issueCount > 1) {
+ return `${firstIssue.message} (+${issueCount - 1} more degraded reads)`;
+ }
+ return firstIssue.message;
+};
+
const getConnectionHealthPresentation = (connection: VMwareConnection) => {
if (!connection.enabled) {
return {
label: 'Disabled',
className: 'bg-surface text-muted',
detail: 'Manual validation paused',
- error: null,
+ note: null,
+ noteClassName: '',
};
}
@@ -51,7 +63,18 @@ const getConnectionHealthPresentation = (connection: VMwareConnection) => {
detail: lastError.at
? `Last check ${formatRelativeTime(lastError.at, { compact: true })}`
: 'Last check failed',
- error: lastError.message || null,
+ note: lastError.message || null,
+ noteClassName: 'text-red-700 dark:text-red-300',
+ };
+ }
+
+ if (lastSuccessAt && connection.observed?.degraded) {
+ return {
+ label: 'Degraded',
+ className: 'bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300',
+ detail: `Last check ${formatRelativeTime(lastSuccessAt, { compact: true })} with partial enrichment`,
+ note: getObservedIssueSummary(connection),
+ noteClassName: 'text-amber-700 dark:text-amber-300',
};
}
@@ -60,7 +83,8 @@ const getConnectionHealthPresentation = (connection: VMwareConnection) => {
label: 'Healthy',
className: 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300',
detail: `Last check ${formatRelativeTime(lastSuccessAt, { compact: true })}`,
- error: null,
+ note: null,
+ noteClassName: '',
};
}
@@ -68,7 +92,8 @@ const getConnectionHealthPresentation = (connection: VMwareConnection) => {
label: 'Awaiting first poll',
className: 'bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300',
detail: 'Pulse has not completed the first vCenter poll yet',
- error: null,
+ note: null,
+ noteClassName: '',
};
};
@@ -255,9 +280,9 @@ export const VMwareSettingsPanel: Component<VMwareSettingsPanelProps> = (props)
</Show>
</div>
- <Show when={health().error}>
- <p class="text-xs font-medium text-red-700 dark:text-red-300">
- {health().error}
+ <Show when={health().note}>
+ <p class={`text-xs font-medium ${health().noteClassName}`}>
+ {health().note}
</p>
</Show>
</div>
@@ -286,6 +311,12 @@ export const VMwareSettingsPanel: Component<VMwareSettingsPanelProps> = (props)
VI JSON {connection.observed?.viRelease}
</span>
</Show>
+ <Show when={connection.observed?.degraded}>
+ <span class="inline-flex items-center rounded-full border border-amber-300 bg-amber-50 px-2 py-0.5 text-xs font-medium text-amber-700 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-300">
+ {formatNumber(connection.observed?.issueCount ?? 0)} degraded{' '}
+ {pluralize(connection.observed?.issueCount ?? 0, 'read')}
+ </span>
+ </Show>
</div>
</div>
</Show>
diff --git a/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx b/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx
index d7a40e90d5..1e7986dfc5 100644
--- a/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx
+++ b/frontend-modern/src/components/Settings/__tests__/VMwareSettingsPanel.test.tsx
@@ -108,6 +108,34 @@ describe('VMwareSettingsPanel', () => {
insecureSkipVerify: true,
enabled: false,
},
+ {
+ id: 'conn-3',
+ name: 'partial-vcenter',
+ host: 'partial.lab.local',
+ username: '[email protected]',
+ insecureSkipVerify: false,
+ enabled: true,
+ poll: {
+ lastSuccessAt: new Date(Date.now() - 120_000).toISOString(),
+ },
+ observed: {
+ collectedAt: new Date(Date.now() - 120_000).toISOString(),
+ hosts: 2,
+ vms: 18,
+ datastores: 4,
+ viRelease: '8.0.3',
+ degraded: true,
+ issueCount: 3,
+ issues: [
+ {
+ stage: 'signals',
+ category: 'permission',
+ message: 'VMware permissions are insufficient for host overall status',
+ occurrences: 2,
+ },
+ ],
+ },
+ },
]);
renderPanel();
@@ -119,10 +147,22 @@ describe('VMwareSettingsPanel', () => {
expect(
within(screen.getByTestId('vmware-connection-conn-2')).getAllByText('Disabled'),
).toHaveLength(2);
+ expect(screen.getByText('partial-vcenter')).toBeInTheDocument();
+ expect(screen.getByText('Degraded')).toBeInTheDocument();
expect(screen.getByText('3 hosts')).toBeInTheDocument();
expect(screen.getByText('42 vms')).toBeInTheDocument();
expect(screen.getByText('6 datastores')).toBeInTheDocument();
- expect(screen.getByText('VI JSON 8.0.3')).toBeInTheDocument();
+ expect(
+ within(screen.getByTestId('vmware-connection-conn-1')).getByText('VI JSON 8.0.3'),
+ ).toBeInTheDocument();
+ expect(
+ within(screen.getByTestId('vmware-connection-conn-3')).getByText('3 degraded reads'),
+ ).toBeInTheDocument();
+ expect(
+ within(screen.getByTestId('vmware-connection-conn-3')).getByText(
+ /VMware permissions are insufficient for host overall status/,
+ ),
+ ).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'Add VMware connection' })).toBeInTheDocument();
fireEvent.click(screen.getByRole('button', { name: 'Add VMware connection' }));
diff --git a/internal/api/vmware_handlers_test.go b/internal/api/vmware_handlers_test.go
index 78f4a217eb..6df8fabc25 100644
--- a/internal/api/vmware_handlers_test.go
+++ b/internal/api/vmware_handlers_test.go
@@ -212,6 +212,71 @@ func TestVMwareHandlers_HandleDelete_RemovesAndClearsRuntimeSummary(t *testing.T
}
}
+func TestVMwareHandlers_HandleList_CarriesDegradedObservedSummary(t *testing.T) {
+ setVMwareFeatureForTest(t, true)
+
+ handler, persistence := newVMwareHandlersForTest(t)
+ if err := persistence.SaveVMwareConfig([]config.VMwareVCenterInstance{
+ {
+ ID: "vc-1",
+ Name: "lab-a",
+ Host: "vcsa-a.lab.local",
+ Port: 443,
+ Username: "[email protected]",
+ Password: "secret-a",
+ Enabled: true,
+ },
+ }); err != nil {
+ t.Fatalf("seed vmware config: %v", err)
+ }
+
+ recordedAt := time.Date(2026, 3, 31, 10, 11, 12, 0, time.UTC)
+ handler.statusMu.Lock()
+ handler.statuses = map[string]vmwareConnectionRuntimeStatus{
+ "vc-1": {
+ Poll: &monitoring.VMwareConnectionPollStatus{
+ IntervalSeconds: 60,
+ LastSuccessAt: &recordedAt,
+ },
+ Observed: &monitoring.VMwareConnectionObservedSummary{
+ CollectedAt: &recordedAt,
+ Hosts: 3,
+ VMs: 42,
+ Datastores: 6,
+ VIRelease: "8.0.3",
+ Degraded: true,
+ IssueCount: 2,
+ Issues: []monitoring.VMwareConnectionObservedIssue{
+ {Stage: "signals", Category: "permission", Message: "VMware permissions are insufficient for host overall status", Occurrences: 2},
+ },
+ },
+ },
+ }
+ handler.statusMu.Unlock()
+
+ req := httptest.NewRequest(http.MethodGet, "/api/vmware/connections", nil)
+ rec := httptest.NewRecorder()
+ handler.HandleList(rec, req)
+
+ if rec.Code != http.StatusOK {
+ t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String())
+ }
+
+ var listed []vmwareConnectionResponse
+ if err := json.NewDecoder(rec.Body).Decode(&listed); err != nil {
+ t.Fatalf("decode list response: %v", err)
+ }
+ if len(listed) != 1 || listed[0].Observed == nil {
+ t.Fatalf("expected degraded observed summary, got %+v", listed)
+ }
+ if !listed[0].Observed.Degraded || listed[0].Observed.IssueCount != 2 {
+ t.Fatalf("unexpected degraded observed summary: %+v", listed[0].Observed)
+ }
+ if len(listed[0].Observed.Issues) != 1 || listed[0].Observed.Issues[0].Occurrences != 2 {
+ t.Fatalf("unexpected observed issues: %+v", listed[0].Observed.Issues)
+ }
+}
+
func TestVMwareHandlers_HandleUpdate_PreservesMaskedSecretsAndReplacesFields(t *testing.T) {
setVMwareFeatureForTest(t, true)
setMockModeForVMwareTest(t, false)
diff --git a/internal/monitoring/canonical_guardrails_test.go b/internal/monitoring/canonical_guardrails_test.go
index 7981578048..8bbf5c9470 100644
--- a/internal/monitoring/canonical_guardrails_test.go
+++ b/internal/monitoring/canonical_guardrails_test.go
@@ -125,6 +125,9 @@ func TestVMwarePollerUsesCanonicalSupplementalIngestOwnership(t *testing.T) {
"func (p *VMwarePoller) ConnectionSummaries(orgID string, instances []config.VMwareVCenterInstance) map[string]VMwareConnectionSummary {",
"func (p *VMwarePoller) RecordConnectionTestSuccess(orgID, connID string, summary *vmware.InventorySummary, at time.Time) {",
"func (p *VMwarePoller) RecordConnectionTestFailure(orgID, connID string, err error, at time.Time) {",
+ "summary.Degraded = true",
+ "summary.IssueCount = len(snapshot.EnrichmentIssues)",
+ "summary.Issues = summarizeVMwareObservedIssues(snapshot.EnrichmentIssues)",
}
for _, snippet := range requiredSnippets {
if !strings.Contains(source, snippet) {
diff --git a/internal/monitoring/vmware_poller.go b/internal/monitoring/vmware_poller.go
index 2764c23af4..6634c573cb 100644
--- a/internal/monitoring/vmware_poller.go
+++ b/internal/monitoring/vmware_poller.go
@@ -37,11 +37,23 @@ type VMwareConnectionPollStatus struct {
// VMwareConnectionObservedSummary summarizes the canonical resources the most
// recent successful poll contributed for one configured VMware connection.
type VMwareConnectionObservedSummary struct {
- CollectedAt *time.Time `json:"collectedAt,omitempty"`
- Hosts int `json:"hosts"`
- VMs int `json:"vms"`
- Datastores int `json:"datastores"`
- VIRelease string `json:"viRelease,omitempty"`
+ CollectedAt *time.Time `json:"collectedAt,omitempty"`
+ Hosts int `json:"hosts"`
+ VMs int `json:"vms"`
+ Datastores int `json:"datastores"`
+ VIRelease string `json:"viRelease,omitempty"`
+ Degraded bool `json:"degraded,omitempty"`
+ IssueCount int `json:"issueCount,omitempty"`
+ Issues []VMwareConnectionObservedIssue `json:"issues,omitempty"`
+}
+
+// VMwareConnectionObservedIssue summarizes one class of optional VMware reads
+// that degraded an otherwise successful inventory refresh.
+type VMwareConnectionObservedIssue struct {
+ Stage string `json:"stage,omitempty"`
+ Category string `json:"category,omitempty"`
+ Message string `json:"message,omitempty"`
+ Occurrences int `json:"occurrences,omitempty"`
}
// VMwareConnectionSummary merges poll health with the most recent discovered
@@ -390,6 +402,15 @@ func (p *VMwarePoller) pollConnection(ctx context.Context, entry vmwarePollerPro
records := cloneIngestRecords(entry.provider.Records())
changes := cloneResourceChanges(entry.provider.ActivityChanges())
snapshot := entry.provider.Snapshot()
+ if snapshot != nil && len(snapshot.EnrichmentIssues) > 0 {
+ log.Warn().
+ Str("component", "vmware_poller").
+ Str("action", "refresh_partial").
+ Str("org_id", entry.orgID).
+ Str("connection_id", entry.connectionID).
+ Int("issue_count", len(snapshot.EnrichmentIssues)).
+ Msg("VMware poller refreshed base inventory with degraded optional enrichment")
+ }
p.mu.Lock()
p.recordConnectionSuccessLocked(entry.orgID, entry.connectionID, at, snapshot)
@@ -769,13 +790,19 @@ func buildVMwareObservedSummary(snapshot *vmware.InventorySnapshot) *VMwareConne
return nil
}
collectedAt := snapshot.CollectedAt
- return &VMwareConnectionObservedSummary{
+ summary := &VMwareConnectionObservedSummary{
CollectedAt: timePointerIfSet(collectedAt),
Hosts: len(snapshot.Hosts),
VMs: len(snapshot.VMs),
Datastores: len(snapshot.Datastores),
VIRelease: strings.TrimSpace(snapshot.VIRelease),
}
+ if len(snapshot.EnrichmentIssues) > 0 {
+ summary.Degraded = true
+ summary.IssueCount = len(snapshot.EnrichmentIssues)
+ summary.Issues = summarizeVMwareObservedIssues(snapshot.EnrichmentIssues)
+ }
+ return summary
}
func classifyVMwarePollError(err error) string {
@@ -818,5 +845,72 @@ func cloneVMwareObservedSummary(value *VMwareConnectionObservedSummary) *VMwareC
VMs: value.VMs,
Datastores: value.Datastores,
VIRelease: strings.TrimSpace(value.VIRelease),
+ Degraded: value.Degraded,
+ IssueCount: value.IssueCount,
+ Issues: cloneVMwareObservedIssues(value.Issues),
}
}
+
+func summarizeVMwareObservedIssues(issues []vmware.InventoryEnrichmentIssue) []VMwareConnectionObservedIssue {
+ if len(issues) == 0 {
+ return nil
+ }
+
+ type aggregate struct {
+ issue VMwareConnectionObservedIssue
+ }
+
+ byKey := make(map[string]*aggregate, len(issues))
+ for _, issue := range issues {
+ key := strings.ToLower(strings.TrimSpace(issue.Stage)) + "\x00" +
+ strings.ToLower(strings.TrimSpace(issue.Category)) + "\x00" +
+ strings.ToLower(strings.TrimSpace(issue.Message))
+ entry := byKey[key]
+ if entry == nil {
+ entry = &aggregate{
+ issue: VMwareConnectionObservedIssue{
+ Stage: strings.TrimSpace(issue.Stage),
+ Category: strings.TrimSpace(issue.Category),
+ Message: strings.TrimSpace(issue.Message),
+ },
+ }
+ byKey[key] = entry
+ }
+ entry.issue.Occurrences++
+ }
+
+ summary := make([]VMwareConnectionObservedIssue, 0, len(byKey))
+ for _, entry := range byKey {
+ summary = append(summary, entry.issue)
+ }
+ sort.Slice(summary, func(i, j int) bool {
+ if summary[i].Occurrences != summary[j].Occurrences {
+ return summary[i].Occurrences > summary[j].Occurrences
+ }
+ if summary[i].Stage != summary[j].Stage {
+ return summary[i].Stage < summary[j].Stage
+ }
+ if summary[i].Category != summary[j].Category {
+ return summary[i].Category < summary[j].Category
+ }
+ return summary[i].Message < summary[j].Message
+ })
+ if len(summary) > 3 {
+ summary = summary[:3]
+ }
+ return summary
+}
+
+func cloneVMwareObservedIssues(in []VMwareConnectionObservedIssue) []VMwareConnectionObservedIssue {
+ if in == nil {
+ return nil
+ }
+ out := make([]VMwareConnectionObservedIssue, len(in))
+ copy(out, in)
+ for i := range out {
+ out[i].Stage = strings.TrimSpace(out[i].Stage)
+ out[i].Category = strings.TrimSpace(out[i].Category)
+ out[i].Message = strings.TrimSpace(out[i].Message)
+ }
+ return out
+}
diff --git a/internal/monitoring/vmware_poller_test.go b/internal/monitoring/vmware_poller_test.go
index bf61690b7c..f0895bb000 100644
--- a/internal/monitoring/vmware_poller_test.go
+++ b/internal/monitoring/vmware_poller_test.go
@@ -259,3 +259,50 @@ func TestVMwarePollerLiveFailureKeepsCachedRecords(t *testing.T) {
t.Fatalf("expected permission poll error after live failure, got %+v", summary.Poll)
}
}
+
+func TestVMwarePollerPublishesDegradedObservedSummaryOnPartialSuccess(t *testing.T) {
+ poller := NewVMwarePoller(nil, time.Minute)
+ connection := config.NewVMwareVCenterInstance()
+ connection.ID = "vc-partial"
+ connection.Host = "vc.partial.local"
+ connection.Username = "[email protected]"
+ connection.Password = "secret"
+
+ collectedAt := time.Date(2026, 3, 31, 10, 0, 0, 0, time.UTC)
+ poller.newProvider = func(instance config.VMwareVCenterInstance) (vmwarePollerProvider, error) {
+ return vmware.NewProvider(vmware.InventorySnapshot{
+ ConnectionID: instance.ID,
+ CollectedAt: collectedAt,
+ VIRelease: "8.0.3",
+ Hosts: []vmware.InventoryHost{{Host: "host-101", Name: "esxi-01"}},
+ EnrichmentIssues: []vmware.InventoryEnrichmentIssue{
+ {Stage: "signals", EntityType: "host", EntityID: "host-101", Category: "permission", Message: "VMware permissions are insufficient for HostSystem overall status"},
+ {Stage: "signals", EntityType: "vm", EntityID: "vm-201", Category: "permission", Message: "VMware permissions are insufficient for HostSystem overall status"},
+ {Stage: "topology", EntityType: "vm", EntityID: "vm-201", Category: "unavailable", Message: "VMware vm guest identity is temporarily unavailable"},
+ },
+ }), nil
+ }
+ poller.providersByOrg["default"] = map[string]vmwarePollerProvider{}
+ provider, err := poller.newProvider(connection)
+ if err != nil {
+ t.Fatalf("newProvider() error = %v", err)
+ }
+ poller.providersByOrg["default"][connection.ID] = provider
+ poller.configsByOrg["default"] = map[string]config.VMwareVCenterInstance{connection.ID: connection}
+
+ poller.pollAll(context.Background())
+
+ summary := poller.ConnectionSummaries("default", []config.VMwareVCenterInstance{connection})[connection.ID]
+ if summary.Poll == nil || summary.Poll.LastSuccessAt == nil || summary.Poll.LastError != nil {
+ t.Fatalf("expected successful degraded poll summary, got %+v", summary.Poll)
+ }
+ if summary.Observed == nil || !summary.Observed.Degraded || summary.Observed.IssueCount != 3 {
+ t.Fatalf("expected degraded observed summary, got %+v", summary.Observed)
+ }
+ if len(summary.Observed.Issues) != 2 {
+ t.Fatalf("expected aggregated observed issues, got %+v", summary.Observed.Issues)
+ }
+ if summary.Observed.Issues[0].Occurrences != 2 || summary.Observed.Issues[0].Category != "permission" {
+ t.Fatalf("expected aggregated permission issue first, got %+v", summary.Observed.Issues[0])
+ }
+}
diff --git a/internal/vmware/client.go b/internal/vmware/client.go
index 48ccaf3c26..41d4cf7ee1 100644
--- a/internal/vmware/client.go
+++ b/internal/vmware/client.go
@@ -192,14 +192,18 @@ func (c *Client) CollectInventory(ctx context.Context) (*InventorySnapshot, erro
if err != nil {
return nil, err
}
- if err := c.enrichInventorySnapshot(ctx, release, sessionID, refs.PerfManagerMoID, refs.EventManagerMoID, perfCounters, inventory); err != nil {
+ signalIssues, err := c.enrichInventorySnapshot(ctx, release, sessionID, refs.PerfManagerMoID, refs.EventManagerMoID, perfCounters, inventory)
+ if err != nil {
return nil, err
}
- if err := c.enrichInventoryTopology(ctx, automationSessionID, release, sessionID, inventory); err != nil {
+ topologyIssues, err := c.enrichInventoryTopology(ctx, automationSessionID, release, sessionID, inventory)
+ if err != nil {
return nil, err
}
inventory.VIRelease = strings.TrimSpace(release)
inventory.CollectedAt = time.Now().UTC()
+ inventory.EnrichmentIssues = append(inventory.EnrichmentIssues, signalIssues...)
+ inventory.EnrichmentIssues = append(inventory.EnrichmentIssues, topologyIssues...)
return inventory, nil
}
diff --git a/internal/vmware/client_signals.go b/internal/vmware/client_signals.go
index 48486ac3a5..d7c030163d 100644
--- a/internal/vmware/client_signals.go
+++ b/internal/vmware/client_signals.go
@@ -145,9 +145,9 @@ func (c *Client) enrichInventorySnapshot(
eventManagerMoID string,
perfCounters perfCounterCatalog,
snapshot *InventorySnapshot,
-) error {
+) ([]InventoryEnrichmentIssue, error) {
if snapshot == nil {
- return nil
+ return nil, nil
}
cache := &alarmNameCache{names: make(map[string]string)}
@@ -155,6 +155,17 @@ func (c *Client) enrichInventorySnapshot(
var wg sync.WaitGroup
var firstErr error
var firstErrMu sync.Mutex
+ var issues []InventoryEnrichmentIssue
+ var issuesMu sync.Mutex
+
+ recordIssue := func(issue *InventoryEnrichmentIssue) {
+ if issue == nil {
+ return
+ }
+ issuesMu.Lock()
+ issues = append(issues, *issue)
+ issuesMu.Unlock()
+ }
run := func(fn func() error) {
wg.Add(1)
@@ -177,11 +188,15 @@ func (c *Client) enrichInventorySnapshot(
i := i
run(func() error {
signals, err := c.collectManagedEntitySignals(ctx, release, sessionID, "HostSystem", snapshot.Hosts[i].Host, perfManagerMoID, eventManagerMoID, cache, true)
- if err != nil {
+ if issue, ok := classifyInventoryEnrichmentIssue("signals", "host", snapshot.Hosts[i].Host, err); ok {
+ recordIssue(issue)
+ } else if err != nil {
return err
}
metrics, err := c.collectHostPerformanceMetrics(ctx, release, sessionID, perfManagerMoID, perfCounters, snapshot.Hosts[i])
- if err != nil {
+ if issue, ok := classifyInventoryEnrichmentIssue("signals", "host", snapshot.Hosts[i].Host, err); ok {
+ recordIssue(issue)
+ } else if err != nil {
return err
}
snapshot.Hosts[i].OverallStatus = signals.OverallStatus
@@ -197,7 +212,9 @@ func (c *Client) enrichInventorySnapshot(
i := i
run(func() error {
signals, err := c.collectManagedEntitySignals(ctx, release, sessionID, "VirtualMachine", snapshot.VMs[i].VM, perfManagerMoID, eventManagerMoID, cache, true)
- if err != nil {
+ if issue, ok := classifyInventoryEnrichmentIssue("signals", "vm", snapshot.VMs[i].VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil {
return err
}
snapshot.VMs[i].OverallStatus = signals.OverallStatus
@@ -205,11 +222,15 @@ func (c *Client) enrichInventorySnapshot(
snapshot.VMs[i].RecentTasks = signals.RecentTasks
snapshot.VMs[i].RecentEvents = signals.RecentEvents
snapshot.VMs[i].SnapshotCount, err = c.collectVMSnapshotCount(ctx, release, sessionID, snapshot.VMs[i].VM)
- if err != nil && !isVIJSONNotFound(err) {
+ if issue, ok := classifyInventoryEnrichmentIssue("signals", "vm", snapshot.VMs[i].VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
return err
}
metrics, err := c.collectVMPerformanceMetrics(ctx, release, sessionID, perfManagerMoID, perfCounters, snapshot.VMs[i])
- if err != nil {
+ if issue, ok := classifyInventoryEnrichmentIssue("signals", "vm", snapshot.VMs[i].VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil {
return err
}
snapshot.VMs[i].Metrics = metrics
@@ -221,7 +242,9 @@ func (c *Client) enrichInventorySnapshot(
i := i
run(func() error {
signals, err := c.collectManagedEntitySignals(ctx, release, sessionID, "Datastore", snapshot.Datastores[i].Datastore, perfManagerMoID, eventManagerMoID, cache, true)
- if err != nil {
+ if issue, ok := classifyInventoryEnrichmentIssue("signals", "storage", snapshot.Datastores[i].Datastore, err); ok {
+ recordIssue(issue)
+ } else if err != nil {
return err
}
snapshot.Datastores[i].OverallStatus = signals.OverallStatus
@@ -235,8 +258,15 @@ func (c *Client) enrichInventorySnapshot(
wg.Wait()
firstErrMu.Lock()
- defer firstErrMu.Unlock()
- return firstErr
+ err := firstErr
+ firstErrMu.Unlock()
+ if err != nil {
+ return nil, err
+ }
+ sort.Slice(issues, func(i, j int) bool {
+ return inventoryEnrichmentIssueSortKey(issues[i]) < inventoryEnrichmentIssueSortKey(issues[j])
+ })
+ return issues, nil
}
func (c *Client) collectManagedEntitySignals(ctx context.Context, release, sessionID, managedType, managedObjectID, perfManagerMoID, eventManagerMoID string, cache *alarmNameCache, allowNotFound bool) (entitySignals, error) {
diff --git a/internal/vmware/client_test.go b/internal/vmware/client_test.go
index a4d656ee21..c79be08e43 100644
--- a/internal/vmware/client_test.go
+++ b/internal/vmware/client_test.go
@@ -106,6 +106,64 @@ func TestClientCollectInventoryEnrichesSignals(t *testing.T) {
}
}
+func TestClientCollectInventoryPreservesBaseInventoryWhenOptionalEnrichmentDegrades(t *testing.T) {
+ server := newVMwareTestServer(t, vmwareTestServerConfig{
+ denyHostOverallStatus: true,
+ unavailableVMGuestInfo: true,
+ })
+ defer server.Close()
+
+ client, err := NewClient(ClientConfig{
+ Host: server.URL,
+ Username: "admin",
+ Password: "secret",
+ InsecureSkipVerify: true,
+ Timeout: 5 * time.Second,
+ })
+ if err != nil {
+ t.Fatalf("NewClient: %v", err)
+ }
+
+ snapshot, err := client.CollectInventory(context.Background())
+ if err != nil {
+ t.Fatalf("CollectInventory: %v", err)
+ }
+ if snapshot == nil {
+ t.Fatal("expected inventory snapshot")
+ }
+ if len(snapshot.Hosts) != 1 || len(snapshot.VMs) != 1 || len(snapshot.Datastores) != 1 {
+ t.Fatalf("unexpected inventory sizes: hosts=%d vms=%d datastores=%d", len(snapshot.Hosts), len(snapshot.VMs), len(snapshot.Datastores))
+ }
+ if len(snapshot.EnrichmentIssues) != 2 {
+ t.Fatalf("expected 2 enrichment issues, got %+v", snapshot.EnrichmentIssues)
+ }
+ if snapshot.EnrichmentIssues[0].Category != "permission" || snapshot.EnrichmentIssues[0].Stage != "signals" {
+ t.Fatalf("unexpected first enrichment issue: %+v", snapshot.EnrichmentIssues[0])
+ }
+ if snapshot.EnrichmentIssues[1].Category != "unavailable" || snapshot.EnrichmentIssues[1].Stage != "topology" {
+ t.Fatalf("unexpected second enrichment issue: %+v", snapshot.EnrichmentIssues[1])
+ }
+
+ host := snapshot.Hosts[0]
+ if host.OverallStatus != "" {
+ t.Fatalf("expected missing host overall status after degraded read, got %q", host.OverallStatus)
+ }
+ if host.Metrics == nil || host.Metrics.CPUPercent == nil || *host.Metrics.CPUPercent != 21.4 {
+ t.Fatalf("expected host metrics to survive degraded signal read, got %+v", host.Metrics)
+ }
+ if host.ClusterName != "Prod Compute" || host.DatacenterName != "DC1" {
+ t.Fatalf("expected host placement enrichment to survive degraded signal read, got cluster=%q datacenter=%q", host.ClusterName, host.DatacenterName)
+ }
+
+ vm := snapshot.VMs[0]
+ if vm.GuestHostname != "" || len(vm.GuestIPAddresses) != 0 {
+ t.Fatalf("expected guest identity to stay empty after degraded topology read, got host=%q ips=%v", vm.GuestHostname, vm.GuestIPAddresses)
+ }
+ if vm.RuntimeHostName != "esxi-01.lab.local" || vm.ResourcePoolName != "Tier 1" {
+ t.Fatalf("expected other topology enrichment to survive degraded guest read, got host=%q pool=%q", vm.RuntimeHostName, vm.ResourcePoolName)
+ }
+}
+
func TestClientTestConnectionRequiresSignalFloor(t *testing.T) {
server := newVMwareTestServer(t, vmwareTestServerConfig{
omitHostOverallStatus: true,
@@ -206,7 +264,9 @@ func TestClientResolveVIJSONReleaseClassifiesUnsupportedVersionFloor(t *testing.
}
type vmwareTestServerConfig struct {
- omitHostOverallStatus bool
+ omitHostOverallStatus bool
+ denyHostOverallStatus bool
+ unavailableVMGuestInfo bool
}
func newVMwareTestServer(t *testing.T, cfg vmwareTestServerConfig) *httptest.Server {
@@ -270,6 +330,10 @@ func newVMwareTestServer(t *testing.T, cfg vmwareTestServerConfig) *httptest.Ser
})
mux.HandleFunc("/api/vcenter/vm/vm-201/guest/identity", func(w http.ResponseWriter, r *http.Request) {
requireAutomationSession(t, r)
+ if cfg.unavailableVMGuestInfo {
+ http.Error(w, "service unavailable", http.StatusServiceUnavailable)
+ return
+ }
writeJSON(w, map[string]any{
"family": "LINUX",
"host_name": "app-01.internal",
@@ -446,6 +510,10 @@ func newVMwareTestServer(t *testing.T, cfg vmwareTestServerConfig) *httptest.Ser
if !cfg.omitHostOverallStatus {
mux.HandleFunc("/sdk/vim25/9.0.0.0/HostSystem/host-101/overallStatus", func(w http.ResponseWriter, r *http.Request) {
requireVISession(t, r)
+ if cfg.denyHostOverallStatus {
+ http.Error(w, "forbidden", http.StatusForbidden)
+ return
+ }
writeJSON(w, "yellow")
})
}
diff --git a/internal/vmware/client_topology.go b/internal/vmware/client_topology.go
index 313c4052c2..0ef198d258 100644
--- a/internal/vmware/client_topology.go
+++ b/internal/vmware/client_topology.go
@@ -80,9 +80,9 @@ func (c *Client) enrichInventoryTopology(
release string,
sessionID string,
snapshot *InventorySnapshot,
-) error {
+) ([]InventoryEnrichmentIssue, error) {
if snapshot == nil {
- return nil
+ return nil, nil
}
hostNamesByID := make(map[string]string, len(snapshot.Hosts))
@@ -103,6 +103,17 @@ func (c *Client) enrichInventoryTopology(
var wg sync.WaitGroup
var firstErr error
var firstErrMu sync.Mutex
+ var issues []InventoryEnrichmentIssue
+ var issuesMu sync.Mutex
+
+ recordIssues := func(values []InventoryEnrichmentIssue) {
+ if len(values) == 0 {
+ return
+ }
+ issuesMu.Lock()
+ issues = append(issues, values...)
+ issuesMu.Unlock()
+ }
run := func(fn func() error) {
wg.Add(1)
@@ -124,10 +135,11 @@ func (c *Client) enrichInventoryTopology(
for i := range snapshot.Hosts {
i := i
run(func() error {
- host, err := c.enrichHostTopology(ctx, release, sessionID, snapshot.Hosts[i], cache, datastoreNamesByID)
+ host, hostIssues, err := c.enrichHostTopology(ctx, release, sessionID, snapshot.Hosts[i], cache, datastoreNamesByID)
if err != nil {
return err
}
+ recordIssues(hostIssues)
snapshot.Hosts[i] = host
return nil
})
@@ -136,7 +148,7 @@ func (c *Client) enrichInventoryTopology(
for i := range snapshot.VMs {
i := i
run(func() error {
- vm, err := c.enrichVMTopology(
+ vm, vmIssues, err := c.enrichVMTopology(
ctx,
automationSessionID,
release,
@@ -149,6 +161,7 @@ func (c *Client) enrichInventoryTopology(
if err != nil {
return err
}
+ recordIssues(vmIssues)
snapshot.VMs[i] = vm
return nil
})
@@ -157,10 +170,11 @@ func (c *Client) enrichInventoryTopology(
for i := range snapshot.Datastores {
i := i
run(func() error {
- datastore, err := c.enrichDatastoreTopology(ctx, release, sessionID, snapshot.Datastores[i], cache, hostNamesByID, vmNamesByID)
+ datastore, datastoreIssues, err := c.enrichDatastoreTopology(ctx, release, sessionID, snapshot.Datastores[i], cache, hostNamesByID, vmNamesByID)
if err != nil {
return err
}
+ recordIssues(datastoreIssues)
snapshot.Datastores[i] = datastore
return nil
})
@@ -169,8 +183,15 @@ func (c *Client) enrichInventoryTopology(
wg.Wait()
firstErrMu.Lock()
- defer firstErrMu.Unlock()
- return firstErr
+ err := firstErr
+ firstErrMu.Unlock()
+ if err != nil {
+ return nil, err
+ }
+ sort.Slice(issues, func(i, j int) bool {
+ return inventoryEnrichmentIssueSortKey(issues[i]) < inventoryEnrichmentIssueSortKey(issues[j])
+ })
+ return issues, nil
}
func (c *Client) enrichHostTopology(
@@ -180,22 +201,33 @@ func (c *Client) enrichHostTopology(
host InventoryHost,
cache *vmwareTopologyCache,
datastoreNamesByID map[string]string,
-) (InventoryHost, error) {
+) (InventoryHost, []InventoryEnrichmentIssue, error) {
+ var issues []InventoryEnrichmentIssue
+ recordIssue := func(issue *InventoryEnrichmentIssue) {
+ if issue != nil {
+ issues = append(issues, *issue)
+ }
+ }
+
ref := viJSONReference{Type: "HostSystem", Value: strings.TrimSpace(host.Host)}
placement, err := cache.resolvePlacement(ctx, c, release, sessionID, ref)
- if err != nil && !isVIJSONNotFound(err) {
- return host, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "host", host.Host, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return host, nil, err
}
applyPlacementToHost(&host, placement)
datastoreRefs, err := c.collectEntityReferenceList(ctx, release, sessionID, "HostSystem", host.Host, "datastore", "host datastore attachments")
- if err != nil && !isVIJSONNotFound(err) {
- return host, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "host", host.Host, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return host, nil, err
}
host.DatastoreIDs = idsForReferences(datastoreRefs)
host.DatastoreNames = namesForReferences(datastoreRefs, datastoreNamesByID)
- return host, nil
+ return host, issues, nil
}
func (c *Client) enrichVMTopology(
@@ -207,10 +239,19 @@ func (c *Client) enrichVMTopology(
cache *vmwareTopologyCache,
hostNamesByID map[string]string,
datastoreNamesByID map[string]string,
-) (InventoryVM, error) {
+) (InventoryVM, []InventoryEnrichmentIssue, error) {
+ var issues []InventoryEnrichmentIssue
+ recordIssue := func(issue *InventoryEnrichmentIssue) {
+ if issue != nil {
+ issues = append(issues, *issue)
+ }
+ }
+
vmInfo, err := c.collectVMAutomationInfo(ctx, automationSessionID, vm.VM)
- if err != nil && !isAutomationNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isAutomationNotFound(err) {
+ return vm, nil, err
}
if vmInfo != nil && vmInfo.Identity != nil {
vm.InstanceUUID = strings.TrimSpace(vmInfo.Identity.InstanceUUID)
@@ -218,8 +259,10 @@ func (c *Client) enrichVMTopology(
}
guestIdentity, err := c.collectVMGuestIdentity(ctx, automationSessionID, vm.VM)
- if err != nil && !isAutomationNotFound(err) && !isAutomationUnavailable(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isAutomationNotFound(err) && !isAutomationUnavailable(err) {
+ return vm, nil, err
}
if guestIdentity != nil {
vm.GuestOSFamily = strings.TrimSpace(guestIdentity.Family)
@@ -232,65 +275,83 @@ func (c *Client) enrichVMTopology(
var placement vmwarePlacement
parentRef, err := c.collectEntityReference(ctx, release, sessionID, "VirtualMachine", vm.VM, "parent", "vm parent placement")
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
if parentRef != nil {
parentPlacement, err := cache.resolvePlacement(ctx, c, release, sessionID, *parentRef)
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
mergePlacement(&placement, parentPlacement)
}
runtimeHostRef, err := c.collectVMRuntimeHostReference(ctx, release, sessionID, vm.VM)
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
if runtimeHostRef != nil {
vm.RuntimeHostID = strings.TrimSpace(runtimeHostRef.Value)
vm.RuntimeHostName = firstNonEmptyTrimmed(hostNamesByID[vm.RuntimeHostID], vm.RuntimeHostID)
hostPlacement, err := cache.resolvePlacement(ctx, c, release, sessionID, *runtimeHostRef)
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
mergePlacement(&placement, hostPlacement)
}
resourcePoolRef, err := c.collectEntityReference(ctx, release, sessionID, "VirtualMachine", vm.VM, "resourcePool", "vm resource pool")
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
if resourcePoolRef != nil {
vm.ResourcePoolID = strings.TrimSpace(resourcePoolRef.Value)
resourcePoolName, err := cache.resolveName(ctx, c, release, sessionID, *resourcePoolRef)
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
vm.ResourcePoolName = firstNonEmptyTrimmed(resourcePoolName, vm.ResourcePoolID)
ownerRef, err := cache.resolveResourcePoolOwner(ctx, c, release, sessionID, *resourcePoolRef)
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
if ownerRef != nil {
ownerPlacement, err := cache.resolvePlacement(ctx, c, release, sessionID, *ownerRef)
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
mergePlacement(&placement, ownerPlacement)
}
}
datastoreRefs, err := c.collectEntityReferenceList(ctx, release, sessionID, "VirtualMachine", vm.VM, "datastore", "vm datastore attachments")
- if err != nil && !isVIJSONNotFound(err) {
- return vm, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "vm", vm.VM, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return vm, nil, err
}
vm.DatastoreIDs = idsForReferences(datastoreRefs)
vm.DatastoreNames = namesForReferences(datastoreRefs, datastoreNamesByID)
applyPlacementToVM(&vm, placement)
- return vm, nil
+ return vm, issues, nil
}
func (c *Client) enrichDatastoreTopology(
@@ -301,17 +362,28 @@ func (c *Client) enrichDatastoreTopology(
cache *vmwareTopologyCache,
hostNamesByID map[string]string,
vmNamesByID map[string]string,
-) (InventoryDatastore, error) {
+) (InventoryDatastore, []InventoryEnrichmentIssue, error) {
+ var issues []InventoryEnrichmentIssue
+ recordIssue := func(issue *InventoryEnrichmentIssue) {
+ if issue != nil {
+ issues = append(issues, *issue)
+ }
+ }
+
ref := viJSONReference{Type: "Datastore", Value: strings.TrimSpace(datastore.Datastore)}
placement, err := cache.resolvePlacement(ctx, c, release, sessionID, ref)
- if err != nil && !isVIJSONNotFound(err) {
- return datastore, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "storage", datastore.Datastore, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return datastore, nil, err
}
applyPlacementToDatastore(&datastore, placement)
summary, err := c.collectDatastoreSummary(ctx, release, sessionID, datastore.Datastore)
- if err != nil && !isVIJSONNotFound(err) {
- return datastore, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "storage", datastore.Datastore, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return datastore, nil, err
}
if summary != nil {
datastore.Accessible = summary.Accessible
@@ -321,20 +393,24 @@ func (c *Client) enrichDatastoreTopology(
}
hostRefs, err := c.collectEntityReferenceList(ctx, release, sessionID, "Datastore", datastore.Datastore, "host", "datastore host attachments")
- if err != nil && !isVIJSONNotFound(err) {
- return datastore, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "storage", datastore.Datastore, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return datastore, nil, err
}
datastore.HostIDs = idsForReferences(hostRefs)
datastore.HostNames = namesForReferences(hostRefs, hostNamesByID)
vmRefs, err := c.collectEntityReferenceList(ctx, release, sessionID, "Datastore", datastore.Datastore, "vm", "datastore vm attachments")
- if err != nil && !isVIJSONNotFound(err) {
- return datastore, err
+ if issue, ok := classifyInventoryEnrichmentIssue("topology", "storage", datastore.Datastore, err); ok {
+ recordIssue(issue)
+ } else if err != nil && !isVIJSONNotFound(err) {
+ return datastore, nil, err
}
datastore.VMIDs = idsForReferences(vmRefs)
datastore.VMNames = namesForReferences(vmRefs, vmNamesByID)
- return datastore, nil
+ return datastore, issues, nil
}
func (c *Client) collectVMAutomationInfo(
diff --git a/internal/vmware/inventory_enrichment.go b/internal/vmware/inventory_enrichment.go
new file mode 100644
index 0000000000..d9d5909fef
--- /dev/null
+++ b/internal/vmware/inventory_enrichment.go
@@ -0,0 +1,35 @@
+package vmware
+
+import (
+ "errors"
+ "strings"
+)
+
+func classifyInventoryEnrichmentIssue(stage, entityType, entityID string, err error) (*InventoryEnrichmentIssue, bool) {
+ if err == nil {
+ return nil, false
+ }
+ var connectionErr *ConnectionError
+ if !errors.As(err, &connectionErr) || connectionErr == nil {
+ return nil, false
+ }
+ if !isNonFatalInventoryEnrichmentCategory(connectionErr.Category) {
+ return nil, false
+ }
+ return &InventoryEnrichmentIssue{
+ Stage: strings.TrimSpace(stage),
+ EntityType: strings.TrimSpace(entityType),
+ EntityID: strings.TrimSpace(entityID),
+ Category: strings.TrimSpace(connectionErr.Category),
+ Message: strings.TrimSpace(connectionErr.Message),
+ }, true
+}
+
+func isNonFatalInventoryEnrichmentCategory(category string) bool {
+ switch strings.ToLower(strings.TrimSpace(category)) {
+ case "permission", "not_found", "unavailable", "endpoint":
+ return true
+ default:
+ return false
+ }
+}
diff --git a/internal/vmware/provider.go b/internal/vmware/provider.go
index ca96e242a6..0c30460f36 100644
--- a/internal/vmware/provider.go
+++ b/internal/vmware/provider.go
@@ -51,6 +51,17 @@ type InventoryMetrics struct {
DiskWriteBytesPerSecond *float64 `json:"disk_write_bytes_per_second,omitempty"`
}
+// InventoryEnrichmentIssue captures one optional VMware read that degraded a
+// successful base inventory refresh without invalidating the core phase-1
+// resource floor.
+type InventoryEnrichmentIssue struct {
+ Stage string `json:"stage,omitempty"`
+ EntityType string `json:"entity_type,omitempty"`
+ EntityID string `json:"entity_id,omitempty"`
+ Category string `json:"category,omitempty"`
+ Message string `json:"message,omitempty"`
+}
+
// InventoryHost is the canonical phase-1 host summary returned by the vCenter
// Automation API list endpoint.
type InventoryHost struct {
@@ -140,14 +151,15 @@ type InventoryDatastore struct {
// InventorySnapshot captures the projected inventory floor for one vCenter
// connection at one point in time.
type InventorySnapshot struct {
- ConnectionID string
- ConnectionName string
- VCenterHost string
- VIRelease string
- CollectedAt time.Time
- Hosts []InventoryHost
- VMs []InventoryVM
- Datastores []InventoryDatastore
+ ConnectionID string
+ ConnectionName string
+ VCenterHost string
+ VIRelease string
+ CollectedAt time.Time
+ Hosts []InventoryHost
+ VMs []InventoryVM
+ Datastores []InventoryDatastore
+ EnrichmentIssues []InventoryEnrichmentIssue
}
// ProviderMetadata carries operator-owned vCenter connection labels onto the
@@ -543,6 +555,10 @@ func sortInventorySnapshot(snapshot *InventorySnapshot) {
sort.Slice(snapshot.Datastores, func(i, j int) bool {
return vmwareSortKey(snapshot.Datastores[i].Datastore, snapshot.Datastores[i].Name) < vmwareSortKey(snapshot.Datastores[j].Datastore, snapshot.Datastores[j].Name)
})
+ sort.Slice(snapshot.EnrichmentIssues, func(i, j int) bool {
+ return inventoryEnrichmentIssueSortKey(snapshot.EnrichmentIssues[i]) <
+ inventoryEnrichmentIssueSortKey(snapshot.EnrichmentIssues[j])
+ })
}
func cloneInventorySnapshot(in *InventorySnapshot) *InventorySnapshot {
@@ -553,6 +569,7 @@ func cloneInventorySnapshot(in *InventorySnapshot) *InventorySnapshot {
out.Hosts = cloneInventoryHosts(in.Hosts)
out.VMs = cloneInventoryVMs(in.VMs)
out.Datastores = cloneInventoryDatastores(in.Datastores)
+ out.EnrichmentIssues = cloneInventoryEnrichmentIssues(in.EnrichmentIssues)
return &out
}
@@ -638,6 +655,23 @@ func cloneInventoryEvents(in []InventoryEvent) []InventoryEvent {
return out
}
+func cloneInventoryEnrichmentIssues(in []InventoryEnrichmentIssue) []InventoryEnrichmentIssue {
+ if in == nil {
+ return nil
+ }
+ out := make([]InventoryEnrichmentIssue, len(in))
+ copy(out, in)
+ return out
+}
+
+func inventoryEnrichmentIssueSortKey(issue InventoryEnrichmentIssue) string {
+ return strings.ToLower(strings.TrimSpace(issue.Stage)) + "\x00" +
+ strings.ToLower(strings.TrimSpace(issue.EntityType)) + "\x00" +
+ strings.ToLower(strings.TrimSpace(issue.EntityID)) + "\x00" +
+ strings.ToLower(strings.TrimSpace(issue.Category)) + "\x00" +
+ strings.ToLower(strings.TrimSpace(issue.Message))
+}
+
func cloneInventoryMetrics(in *InventoryMetrics) *InventoryMetrics {
if in == nil {
return nil
diff --git a/tests/integration/tests/22-vmware-settings-platform-connections.spec.ts b/tests/integration/tests/22-vmware-settings-platform-connections.spec.ts
index 73bdce308c..164b55ca16 100644
--- a/tests/integration/tests/22-vmware-settings-platform-connections.spec.ts
+++ b/tests/integration/tests/22-vmware-settings-platform-connections.spec.ts
@@ -1,8 +1,8 @@
-import fs from 'node:fs';
-import path from 'node:path';
-import { fileURLToPath } from 'node:url';
-import { test as base, expect } from '@playwright/test';
-import { createAuthenticatedStorageState } from './helpers';
+import fs from "node:fs";
+import path from "node:path";
+import { fileURLToPath } from "node:url";
+import { test as base, expect } from "@playwright/test";
+import { createAuthenticatedStorageState } from "./helpers";
const __dirname = path.dirname(fileURLToPath(import.meta.url));
@@ -12,68 +12,71 @@ type WorkerFixtures = {
const SCREENSHOT_PATH = path.resolve(
__dirname,
- '..',
- '..',
- 'tmp',
- 'vmware-settings-platform-connections.png',
+ "..",
+ "..",
+ "tmp",
+ "vmware-settings-platform-connections.png",
);
const WORKFLOW_SCREENSHOT_PATH = path.resolve(
__dirname,
- '..',
- '..',
- 'tmp',
- 'vmware-settings-platform-workflow.png',
+ "..",
+ "..",
+ "tmp",
+ "vmware-settings-platform-workflow.png",
);
const test = base.extend<{}, WorkerFixtures>({
storageState: async ({ authStorageStatePath }, use) => {
await use(authStorageStatePath);
},
- authStorageStatePath: [async ({ browser }, use, workerInfo) => {
- const storageStatePath = path.resolve(
- __dirname,
- '..',
- '..',
- 'tmp',
- 'playwright-auth',
- `vmware-settings-platform-connections-${workerInfo.project.name}.json`,
- );
- fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });
- await createAuthenticatedStorageState(browser, storageStatePath);
- try {
- await use(storageStatePath);
- } finally {
- fs.rmSync(storageStatePath, { force: true });
- }
- }, { scope: 'worker' }],
+ authStorageStatePath: [
+ async ({ browser }, use, workerInfo) => {
+ const storageStatePath = path.resolve(
+ __dirname,
+ "..",
+ "..",
+ "tmp",
+ "playwright-auth",
+ `vmware-settings-platform-connections-${workerInfo.project.name}.json`,
+ );
+ fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });
+ await createAuthenticatedStorageState(browser, storageStatePath);
+ try {
+ await use(storageStatePath);
+ } finally {
+ fs.rmSync(storageStatePath, { force: true });
+ }
+ },
+ { scope: "worker" },
+ ],
});
-test.describe('VMware platform connections settings', () => {
+test.describe("VMware platform connections settings", () => {
test.setTimeout(180_000);
- test('renders the platform-connections workspace with the VMware integration shell', async ({
+ test("renders the platform-connections workspace with the VMware integration shell", async ({
page,
}) => {
const healthyAt = new Date(Date.now() - 5 * 60_000).toISOString();
const failingAt = new Date(Date.now() - 2 * 60_000).toISOString();
- await page.route('**/api/vmware/connections', async (route) => {
- if (route.request().method() !== 'GET') {
+ await page.route("**/api/vmware/connections", async (route) => {
+ if (route.request().method() !== "GET") {
await route.continue();
return;
}
await route.fulfill({
status: 200,
- contentType: 'application/json',
+ contentType: "application/json",
body: JSON.stringify([
{
- id: 'vmware-1',
- name: 'Primary vCenter',
- host: 'vcsa-primary.local',
+ id: "vmware-1",
+ name: "Primary vCenter",
+ host: "vcsa-primary.local",
port: 443,
- username: '[email protected]',
- password: '********',
+ username: "[email protected]",
+ password: "********",
insecureSkipVerify: false,
enabled: true,
poll: {
@@ -84,80 +87,128 @@ test.describe('VMware platform connections settings', () => {
hosts: 6,
vms: 120,
datastores: 18,
- viRelease: '8.0.3',
+ viRelease: "8.0.3",
},
},
{
- id: 'vmware-2',
- name: 'Staging vCenter',
- host: 'vcsa-staging.local',
+ id: "vmware-2",
+ name: "Staging vCenter",
+ host: "vcsa-staging.local",
port: 443,
- username: '[email protected]',
- password: '********',
+ username: "[email protected]",
+ password: "********",
insecureSkipVerify: true,
enabled: true,
poll: {
lastAttemptAt: failingAt,
lastError: {
at: failingAt,
- message: 'authentication failed',
- category: 'auth',
+ message: "authentication failed",
+ category: "auth",
},
},
},
+ {
+ id: "vmware-3",
+ name: "Partial vCenter",
+ host: "vcsa-partial.local",
+ port: 443,
+ username: "[email protected]",
+ password: "********",
+ insecureSkipVerify: false,
+ enabled: true,
+ poll: {
+ lastSuccessAt: healthyAt,
+ },
+ observed: {
+ collectedAt: healthyAt,
+ hosts: 2,
+ vms: 18,
+ datastores: 4,
+ viRelease: "8.0.3",
+ degraded: true,
+ issueCount: 3,
+ issues: [
+ {
+ stage: "signals",
+ category: "permission",
+ message:
+ "VMware permissions are insufficient for host overall status",
+ occurrences: 2,
+ },
+ ],
+ },
+ },
]),
});
});
- await page.goto('/settings/infrastructure/platforms/vmware', {
- waitUntil: 'domcontentloaded',
+ await page.goto("/settings/infrastructure/platforms/vmware", {
+ waitUntil: "domcontentloaded",
});
await page.waitForURL(/\/settings\/infrastructure\/platforms\/vmware/, {
timeout: 15_000,
});
await expect(
- page.getByRole('heading', { level: 1, name: 'Infrastructure Operations' }),
+ page.getByRole("heading", {
+ level: 1,
+ name: "Infrastructure Operations",
+ }),
).toBeVisible();
- await expect(page.getByRole('tab', { name: 'Platform connections' })).toHaveAttribute(
- 'aria-selected',
- 'true',
- );
- await expect(page.getByRole('tab', { name: 'VMware' })).toHaveAttribute(
- 'aria-selected',
- 'true',
+ await expect(
+ page.getByRole("tab", { name: "Platform connections" }),
+ ).toHaveAttribute("aria-selected", "true");
+ await expect(page.getByRole("tab", { name: "VMware" })).toHaveAttribute(
+ "aria-selected",
+ "true",
);
- await expect(page.getByRole('tab', { name: 'TrueNAS' })).toHaveAttribute(
- 'aria-selected',
- 'false',
+ await expect(page.getByRole("tab", { name: "TrueNAS" })).toHaveAttribute(
+ "aria-selected",
+ "false",
);
- await expect(page.getByRole('tab', { name: 'Proxmox' })).toHaveAttribute(
- 'aria-selected',
- 'false',
+ await expect(page.getByRole("tab", { name: "Proxmox" })).toHaveAttribute(
+ "aria-selected",
+ "false",
);
- await expect(page.getByText('VMware vSphere platform integration')).toBeVisible();
- await expect(page.getByRole('button', { name: 'Add VMware connection' })).toBeVisible();
-
- const primaryCard = page.getByTestId('vmware-connection-vmware-1');
- await expect(primaryCard).toContainText('Primary vCenter');
- await expect(primaryCard).toContainText('Healthy');
- await expect(primaryCard).toContainText('6 hosts');
- await expect(primaryCard).toContainText('120 vms');
- await expect(primaryCard).toContainText('18 datastores');
- await expect(primaryCard).toContainText('VI JSON 8.0.3');
+ await expect(
+ page.getByText("VMware vSphere platform integration"),
+ ).toBeVisible();
+ await expect(
+ page.getByRole("button", { name: "Add VMware connection" }),
+ ).toBeVisible();
- const failingCard = page.getByTestId('vmware-connection-vmware-2');
- await expect(failingCard).toContainText('Staging vCenter');
- await expect(failingCard).toContainText('Runtime failing');
- await expect(failingCard).toContainText('authentication failed');
- await expect(failingCard).toContainText('Skip TLS verification');
+ const primaryCard = page.getByTestId("vmware-connection-vmware-1");
+ await expect(primaryCard).toContainText("Primary vCenter");
+ await expect(primaryCard).toContainText("Healthy");
+ await expect(primaryCard).toContainText("6 hosts");
+ await expect(primaryCard).toContainText("120 vms");
+ await expect(primaryCard).toContainText("18 datastores");
+ await expect(primaryCard).toContainText("VI JSON 8.0.3");
+
+ const failingCard = page.getByTestId("vmware-connection-vmware-2");
+ await expect(failingCard).toContainText("Staging vCenter");
+ await expect(failingCard).toContainText("Runtime failing");
+ await expect(failingCard).toContainText("authentication failed");
+ await expect(failingCard).toContainText("Skip TLS verification");
+
+ const partialCard = page.getByTestId("vmware-connection-vmware-3");
+ await expect(partialCard).toContainText("Partial vCenter");
+ await expect(partialCard).toContainText("Degraded");
+ await expect(partialCard).toContainText("2 hosts");
+ await expect(partialCard).toContainText("18 vms");
+ await expect(partialCard).toContainText("4 datastores");
+ await expect(partialCard).toContainText("3 degraded reads");
+ await expect(partialCard).toContainText(
+ "VMware permissions are insufficient for host overall status",
+ );
fs.mkdirSync(path.dirname(SCREENSHOT_PATH), { recursive: true });
await page.screenshot({ path: SCREENSHOT_PATH, fullPage: true });
});
- test('adds, edits, retests, and deletes VMware connections through the canonical settings workflow', async ({
+ test("adds, edits, retests, and deletes VMware connections through the canonical settings workflow", async ({
page,
}) => {
const validatedAt = new Date(Date.now() - 60_000).toISOString();
@@ -166,44 +217,47 @@ test.describe('VMware platform connections settings', () => {
let createPayload: Record<string, unknown> | null = null;
let updatePayload: Record<string, unknown> | null = null;
let draftTestCalls = 0;
- const savedTestRequests: Array<{ path: string; payload: Record<string, unknown> | null }> = [];
+ const savedTestRequests: Array<{
+ path: string;
+ payload: Record<string, unknown> | null;
+ }> = [];
const deletePaths: string[] = [];
- await page.route('**/api/vmware/connections**', async (route) => {
+ await page.route("**/api/vmware/connections**", async (route) => {
const request = route.request();
const method = request.method();
const pathname = new URL(request.url()).pathname;
- if (pathname === '/api/vmware/connections' && method === 'GET') {
+ if (pathname === "/api/vmware/connections" && method === "GET") {
await route.fulfill({
status: 200,
- contentType: 'application/json',
+ contentType: "application/json",
body: JSON.stringify(connections),
});
return;
}
- if (pathname === '/api/vmware/connections/test' && method === 'POST') {
+ if (pathname === "/api/vmware/connections/test" && method === "POST") {
draftTestCalls += 1;
- draftTestPayload = JSON.parse(request.postData() || '{}');
+ draftTestPayload = JSON.parse(request.postData() || "{}");
await route.fulfill({
status: 200,
- contentType: 'application/json',
+ contentType: "application/json",
body: JSON.stringify({ success: true }),
});
return;
}
- if (pathname === '/api/vmware/connections' && method === 'POST') {
- createPayload = JSON.parse(request.postData() || '{}');
+ if (pathname === "/api/vmware/connections" && method === "POST") {
+ createPayload = JSON.parse(request.postData() || "{}");
connections = [
{
- id: 'conn-1',
+ id: "conn-1",
name: createPayload.name,
host: createPayload.host,
port: createPayload.port,
username: createPayload.username,
- password: '********',
+ password: "********",
insecureSkipVerify: createPayload.insecureSkipVerify,
enabled: createPayload.enabled,
poll: {
@@ -214,41 +268,46 @@ test.describe('VMware platform connections settings', () => {
hosts: 4,
vms: 48,
datastores: 8,
- viRelease: '8.0.3',
+ viRelease: "8.0.3",
},
},
];
await route.fulfill({
status: 201,
- contentType: 'application/json',
+ contentType: "application/json",
body: JSON.stringify(connections[0]),
});
return;
}
- if (pathname === '/api/vmware/connections/conn-1/test' && method === 'POST') {
+ if (
+ pathname === "/api/vmware/connections/conn-1/test" &&
+ method === "POST"
+ ) {
savedTestRequests.push({
path: pathname,
- payload: request.postData() ? JSON.parse(request.postData() || '{}') : null,
+ payload: request.postData()
+ ? JSON.parse(request.postData() || "{}")
+ : null,
});
await route.fulfill({
status: 200,
- contentType: 'application/json',
+ contentType: "application/json",
body: JSON.stringify({ success: true }),
});
return;
}
- if (pathname === '/api/vmware/connections/conn-1' && method === 'PUT') {
- updatePayload = JSON.parse(request.postData() || '{}');
+ if (pathname === "/api/vmware/connections/conn-1" && method === "PUT") {
+ updatePayload = JSON.parse(request.postData() || "{}");
connections = [
{
- id: 'conn-1',
+ id: "conn-1",
name: updatePayload.name,
host: updatePayload.host,
port: updatePayload.port,
username: updatePayload.username,
- password: '********',
+ password: "********",
insecureSkipVerify: updatePayload.insecureSkipVerify,
enabled: updatePayload.enabled,
poll: {
@@ -259,25 +318,28 @@ test.describe('VMware platform connections settings', () => {
hosts: 4,
vms: 48,
datastores: 8,
- viRelease: '8.0.3',
+ viRelease: "8.0.3",
},
},
];
await route.fulfill({
status: 200,
- contentType: 'application/json',
+ contentType: "application/json",
body: JSON.stringify(connections[0]),
});
return;
}
- if (pathname === '/api/vmware/connections/conn-1' && method === 'DELETE') {
+ if (
+ pathname === "/api/vmware/connections/conn-1" &&
+ method === "DELETE"
+ ) {
deletePaths.push(pathname);
connections = [];
await route.fulfill({
status: 200,
- contentType: 'application/json',
- body: JSON.stringify({ success: true, id: 'conn-1' }),
+ contentType: "application/json",
+ body: JSON.stringify({ success: true, id: "conn-1" }),
});
return;
}
@@ -285,112 +347,130 @@ test.describe('VMware platform connections settings', () => {
await route.continue();
});
- await page.goto('/settings/infrastructure/platforms/vmware', {
- waitUntil: 'domcontentloaded',
+ await page.goto("/settings/infrastructure/platforms/vmware", {
+ waitUntil: "domcontentloaded",
});
await page.waitForURL(/\/settings\/infrastructure\/platforms\/vmware/, {
timeout: 15_000,
});
- await expect(page.getByText('No VMware connections yet')).toBeVisible();
+ await expect(page.getByText("No VMware connections yet")).toBeVisible();
- await page.getByRole('button', { name: 'Add VMware connection' }).click();
- const dialog = page.getByRole('dialog', { name: 'Add VMware connection' });
+ await page.getByRole("button", { name: "Add VMware connection" }).click();
+ const dialog = page.getByRole("dialog", { name: "Add VMware connection" });
await expect(dialog).toBeVisible();
- await dialog.getByPlaceholder('lab-vcenter').fill('Lab vCenter');
- await dialog.getByPlaceholder('vcsa.lab.local').fill('vcsa.lab.local');
- await dialog.getByPlaceholder('443').fill('443');
- await dialog.getByPlaceholder('[email protected]').fill(
- );
- await dialog.locator('input[type="password"]').first().fill('super-secret');
-
- await dialog.getByRole('button', { name: 'Test connection' }).click();
- await expect.poll(() => draftTestPayload).toMatchObject({
- name: 'Lab vCenter',
- host: 'vcsa.lab.local',
- port: 443,
- username: '[email protected]',
- password: 'super-secret',
- enabled: true,
- insecureSkipVerify: false,
- });
+ await dialog.getByPlaceholder("lab-vcenter").fill("Lab vCenter");
+ await dialog.getByPlaceholder("vcsa.lab.local").fill("vcsa.lab.local");
+ await dialog.getByPlaceholder("443").fill("443");
+ await dialog
+ .getByPlaceholder("[email protected]")
+ .fill("[email protected]");
+ await dialog.locator('input[type="password"]').first().fill("super-secret");
+
+ await dialog.getByRole("button", { name: "Test connection" }).click();
+ await expect
+ .poll(() => draftTestPayload)
+ .toMatchObject({
+ name: "Lab vCenter",
+ host: "vcsa.lab.local",
+ port: 443,
+ username: "[email protected]",
+ password: "super-secret",
+ enabled: true,
+ insecureSkipVerify: false,
+ });
- await dialog.getByRole('button', { name: 'Add connection' }).click();
+ await dialog.getByRole("button", { name: "Add connection" }).click();
- const connectionCard = page.getByTestId('vmware-connection-conn-1');
+ const connectionCard = page.getByTestId("vmware-connection-conn-1");
await expect(connectionCard).toBeVisible();
- await expect(connectionCard).toContainText('Lab vCenter');
- await expect(connectionCard).toContainText('Healthy');
- await expect.poll(() => createPayload).toMatchObject({
- name: 'Lab vCenter',
- host: 'vcsa.lab.local',
- port: 443,
- username: '[email protected]',
- password: 'super-secret',
- enabled: true,
- insecureSkipVerify: false,
- });
+ await expect(connectionCard).toContainText("Lab vCenter");
+ await expect(connectionCard).toContainText("Healthy");
+ await expect
+ .poll(() => createPayload)
+ .toMatchObject({
+ name: "Lab vCenter",
+ host: "vcsa.lab.local",
+ port: 443,
+ username: "[email protected]",
+ password: "super-secret",
+ enabled: true,
+ insecureSkipVerify: false,
+ });
- await connectionCard.getByRole('button', { name: 'Edit' }).click();
- const editDialog = page.getByRole('dialog', { name: 'Edit VMware connection' });
+ await connectionCard.getByRole("button", { name: "Edit" }).click();
+ const editDialog = page.getByRole("dialog", {
+ name: "Edit VMware connection",
+ });
await expect(editDialog).toBeVisible();
await expect(
- editDialog.getByPlaceholder('Saved password retained unless replaced'),
+ editDialog.getByPlaceholder("Saved password retained unless replaced"),
).toBeVisible();
- await editDialog.getByPlaceholder('lab-vcenter').fill('Lab vCenter Edited');
- await editDialog.getByPlaceholder('vcsa.lab.local').fill('edited.lab.local');
- await editDialog.getByPlaceholder('443').fill('8443');
- await editDialog.getByPlaceholder('[email protected]').fill('[email protected]');
- await editDialog.getByLabel('Skip TLS verification').check();
-
- await editDialog.getByRole('button', { name: 'Test connection' }).click();
- await expect.poll(() => savedTestRequests[0]).toMatchObject({
- path: '/api/vmware/connections/conn-1/test',
- payload: {
- name: 'Lab vCenter Edited',
- host: 'edited.lab.local',
+ await editDialog.getByPlaceholder("lab-vcenter").fill("Lab vCenter Edited");
+ await editDialog
+ .getByPlaceholder("vcsa.lab.local")
+ .fill("edited.lab.local");
+ await editDialog.getByPlaceholder("443").fill("8443");
+ await editDialog
+ .getByPlaceholder("[email protected]")
+ .fill("[email protected]");
+ await editDialog.getByLabel("Skip TLS verification").check();
+
+ await editDialog.getByRole("button", { name: "Test connection" }).click();
+ await expect
+ .poll(() => savedTestRequests[0])
+ .toMatchObject({
+ path: "/api/vmware/connections/conn-1/test",
+ payload: {
+ name: "Lab vCenter Edited",
+ host: "edited.lab.local",
+ port: 8443,
+ username: "[email protected]",
+ password: "********",
+ enabled: true,
+ insecureSkipVerify: true,
+ },
+ });
+ await expect.poll(() => draftTestCalls).toBe(1);
+
+ await editDialog.getByRole("button", { name: "Save connection" }).click();
+ await expect
+ .poll(() => updatePayload)
+ .toMatchObject({
+ name: "Lab vCenter Edited",
+ host: "edited.lab.local",
port: 8443,
- username: '[email protected]',
- password: '********',
+ username: "[email protected]",
+ password: "********",
enabled: true,
insecureSkipVerify: true,
- },
- });
- await expect.poll(() => draftTestCalls).toBe(1);
-
- await editDialog.getByRole('button', { name: 'Save connection' }).click();
- await expect.poll(() => updatePayload).toMatchObject({
- name: 'Lab vCenter Edited',
- host: 'edited.lab.local',
- port: 8443,
- username: '[email protected]',
- password: '********',
- enabled: true,
- insecureSkipVerify: true,
- });
- await expect(connectionCard).toContainText('Lab vCenter Edited');
-
- await connectionCard.getByRole('button', { name: 'Test' }).click();
- await expect.poll(() => savedTestRequests).toEqual([
- expect.objectContaining({
- path: '/api/vmware/connections/conn-1/test',
- payload: expect.objectContaining({
- host: 'edited.lab.local',
- password: '********',
- insecureSkipVerify: true,
+ });
+ await expect(connectionCard).toContainText("Lab vCenter Edited");
+
+ await connectionCard.getByRole("button", { name: "Test" }).click();
+ await expect
+ .poll(() => savedTestRequests)
+ .toEqual([
+ expect.objectContaining({
+ path: "/api/vmware/connections/conn-1/test",
+ payload: expect.objectContaining({
+ host: "edited.lab.local",
+ password: "********",
+ insecureSkipVerify: true,
+ }),
}),
- }),
- { path: '/api/vmware/connections/conn-1/test', payload: null },
- ]);
+ { path: "/api/vmware/connections/conn-1/test", payload: null },
+ ]);
await expect.poll(() => draftTestCalls).toBe(1);
- await connectionCard.getByRole('button', { name: 'Delete' }).click();
- await page.getByRole('button', { name: 'Delete connection' }).click();
- await expect.poll(() => deletePaths).toEqual(['/api/vmware/connections/conn-1']);
- await expect(page.getByText('No VMware connections yet')).toBeVisible();
+ await connectionCard.getByRole("button", { name: "Delete" }).click();
+ await page.getByRole("button", { name: "Delete connection" }).click();
+ await expect
+ .poll(() => deletePaths)
+ .toEqual(["/api/vmware/connections/conn-1"]);
+ await expect(page.getByText("No VMware connections yet")).toBeVisible();
fs.mkdirSync(path.dirname(WORKFLOW_SCREENSHOT_PATH), { recursive: true });
await page.screenshot({ path: WORKFLOW_SCREENSHOT_PATH, fullPage: true });