MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / getFreshClusterStatusInternal

Method getFreshClusterStatusInternal

pkg/api/client.go:436–473  ·  view source on GitHub ↗

getFreshClusterStatusInternal is the shared implementation for cluster status retrieval. When enrichVMs is true, running VMs are enriched with guest agent data (slower but more complete).

(enrichVMs bool)

Source from the content-addressed store, hash-verified

434// getFreshClusterStatusInternal is the shared implementation for cluster status retrieval.
435// When enrichVMs is true, running VMs are enriched with guest agent data (slower but more complete).
436func (c *Client) getFreshClusterStatusInternal(enrichVMs bool) (*Cluster, error) {
437 // Selectively clear cluster-level cache entries rather than the entire cache.
438 // Node-level data (disks, updates) is invalidated per-node during enrichment,
439 // so clearing everything here wastes cached data that is still valid.
440 c.ClearClusterCache()
441
442 // Create a fresh cluster with minimal cache TTL for resources
443 cluster := &Cluster{
444 Nodes: make([]*Node, 0),
445 StorageManager: NewStorageManager(),
446 lastUpdate: time.Now(),
447 }
448
449 // 1. Get basic cluster status
450 if err := c.getClusterBasicStatus(cluster); err != nil {
451 return nil, err
452 }
453
454 // 2. Get cluster resources without cache (TTL = 0)
455 if err := c.processClusterResourcesWithCache(cluster, 0); err != nil {
456 return nil, err
457 }
458
459 // 3. Enrich VMs with detailed status information (skipped for light refresh)
460 if enrichVMs {
461 if err := c.EnrichVMs(cluster); err != nil {
462 // Log error but continue
463 c.logger.Debug("[CLUSTER] Error enriching VM data: %v", err)
464 }
465 }
466
467 // 4. Calculate cluster-wide totals
468 c.calculateClusterTotals(cluster)
469
470 c.Cluster = cluster
471
472 return cluster, nil
473}
474
475// RefreshNodeData refreshes data for a specific node by clearing its cache entries and fetching fresh data.
476func (c *Client) RefreshNodeData(nodeName string) (*Node, error) {

Callers 2

GetFreshClusterStatusMethod · 0.95
GetLightClusterStatusMethod · 0.95

Calls 7

ClearClusterCacheMethod · 0.95
getClusterBasicStatusMethod · 0.95
EnrichVMsMethod · 0.95
NewStorageManagerFunction · 0.85
DebugMethod · 0.65

Tested by

no test coverage detected