status

package
v1.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package status provides thread-safe access to CloudZero Agent cluster health reporting. This package implements a builder pattern for constructing and accessing ClusterStatus protobuf messages used for agent health monitoring and diagnostic reporting.

The ClusterStatus report contains comprehensive health information about the CloudZero Agent installation, including connectivity checks, configuration validation, and operational status for all agent components. This data is used by:

  • CloudZero platform for agent health monitoring and alerting
  • Customer operations teams for troubleshooting installation issues
  • Agent components for self-diagnostic and validation reporting

The package provides thread-safe read/write access to shared status data, enabling multiple agent components to contribute health information concurrently without data races or corruption.

Index

Constants

This section is empty.

Variables

View Source
var (
	StatusType_name = map[int32]string{
		0: "STATUS_TYPE_UNSPECIFIED",
		1: "STATUS_TYPE_INIT_STARTED",
		2: "STATUS_TYPE_INIT_OK",
		3: "STATUS_TYPE_INIT_FAILED",
		4: "STATUS_TYPE_POD_STARTED",
		5: "STATUS_TYPE_POD_STOPPING",
	}
	StatusType_value = map[string]int32{
		"STATUS_TYPE_UNSPECIFIED":  0,
		"STATUS_TYPE_INIT_STARTED": 1,
		"STATUS_TYPE_INIT_OK":      2,
		"STATUS_TYPE_INIT_FAILED":  3,
		"STATUS_TYPE_POD_STARTED":  4,
		"STATUS_TYPE_POD_STOPPING": 5,
	}
)

Enum value maps for StatusType.

View Source
var File_cluster_status_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Accessor

type Accessor interface {
	// AddCheck appends one or more status checks to the cluster status report.
	// This method enables agent components to contribute health check results to the
	// comprehensive cluster status without requiring full report reconstruction.
	//
	// Common usage patterns:
	//   - Webhook services adding connectivity and certificate validation results
	//   - Metric collectors reporting Prometheus endpoint health status
	//   - Storage services contributing disk space and persistence health checks
	//   - Network services adding CloudZero API connectivity validation
	//
	// The method is thread-safe and triggers registered write callbacks to notify
	// listeners of status updates, enabling real-time monitoring and alerting.
	//
	// Multiple checks can be added atomically in a single call for efficiency.
	AddCheck(...*StatusCheck)

	// WriteToReport provides exclusive write access to the cluster status report.
	// The provided function receives a pointer to the ClusterStatus protobuf and can
	// make arbitrary modifications while holding the write lock.
	//
	// Used for:
	//   - Bulk status updates requiring consistency across multiple fields
	//   - Complex status calculations that need to read and modify multiple values
	//   - Status reset or initialization operations during agent startup
	//   - Atomic updates to prevent partial status states during report generation
	//
	// The write lock ensures no other goroutines can read or write the status
	// during the function execution, maintaining data consistency and preventing races.
	// Write callbacks are triggered after the function completes and the lock is released.
	WriteToReport(func(*ClusterStatus))

	// ReadFromReport provides shared read access to the cluster status report.
	// The provided function receives a read-only pointer to the ClusterStatus protobuf
	// while holding a read lock that allows concurrent readers but blocks writers.
	//
	// Used for:
	//   - Status report generation for HTTP endpoints and diagnostic tools
	//   - Health check aggregation across multiple agent components
	//   - Status monitoring and alerting that needs consistent snapshots
	//   - Diagnostic logging that requires stable status values during output
	//
	// Multiple goroutines can read simultaneously, but write operations are blocked
	// during read access to ensure the function receives a consistent view of the status.
	// The function should not retain references to the ClusterStatus pointer after return.
	ReadFromReport(func(*ClusterStatus))
}

Accessor defines the interface for thread-safe read/write access to CloudZero Agent cluster status reports. This interface enables multiple agent components to concurrently update and read status information without requiring external synchronization, simplifying status management across the agent architecture.

The Accessor pattern provides controlled access to the shared ClusterStatus protobuf, ensuring data consistency during concurrent status updates from different agent services. Used by agent components including webhook handlers, metric collectors, and health check services.

func NewAccessor

func NewAccessor(s *ClusterStatus, onWrite ...func(*ClusterStatus)) Accessor

NewAccessor creates a new thread-safe Accessor for cluster status management. This constructor initializes the builder with the provided ClusterStatus protobuf and optional write callback functions for status change notifications.

Parameters:

  • s: The ClusterStatus protobuf to manage (usually initialized with default values)
  • onWrite: Optional callback functions executed after each write operation

The returned Accessor enables multiple agent components to safely read and write status information concurrently. Write callbacks are executed in the order provided after each write operation completes and the write lock is released.

Common usage patterns:

  • Agent startup: Create accessor with status upload and logging callbacks
  • Component initialization: Pass accessor to services for health reporting
  • Monitoring integration: Add callbacks for metric collection and alerting

Returns an Accessor interface that provides thread-safe access to the cluster status.

type ClusterStatus

type ClusterStatus struct {
	Account          string         `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
	Region           string         `protobuf:"bytes,2,opt,name=region,proto3" json:"region,omitempty"`
	Name             string         `protobuf:"bytes,3,opt,name=name,proto3" json:"name,omitempty"`
	State            StatusType     `protobuf:"varint,4,opt,name=state,proto3,enum=status.StatusType" json:"state,omitempty"`
	ChartVersion     string         `protobuf:"bytes,5,opt,name=chart_version,json=chartVersion,proto3" json:"chart_version,omitempty"`
	AgentVersion     string         `protobuf:"bytes,6,opt,name=agent_version,json=agentVersion,proto3" json:"agent_version,omitempty"`
	ScrapeConfig     string         `protobuf:"bytes,7,opt,name=scrape_config,json=scrapeConfig,proto3" json:"scrape_config,omitempty"`
	ValidatorVersion string         `protobuf:"bytes,8,opt,name=validator_version,json=validatorVersion,proto3" json:"validator_version,omitempty"`
	K8SVersion       string         `protobuf:"bytes,9,opt,name=k8s_version,json=k8sVersion,proto3" json:"k8s_version,omitempty"`
	Checks           []*StatusCheck `protobuf:"bytes,10,rep,name=checks,proto3" json:"checks,omitempty"`
	// 05/15/25 updates
	ProviderId  string `protobuf:"bytes,11,opt,name=provider_id,json=providerId,proto3" json:"provider_id,omitempty"`
	ReleaseName string `protobuf:"bytes,12,opt,name=release_name,json=releaseName,proto3" json:"release_name,omitempty"`
	Namespace   string `protobuf:"bytes,13,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// contains filtered or unexported fields
}

func (*ClusterStatus) Descriptor deprecated

func (*ClusterStatus) Descriptor() ([]byte, []int)

Deprecated: Use ClusterStatus.ProtoReflect.Descriptor instead.

func (*ClusterStatus) GetAccount

func (x *ClusterStatus) GetAccount() string

func (*ClusterStatus) GetAgentVersion

func (x *ClusterStatus) GetAgentVersion() string

func (*ClusterStatus) GetChartVersion

func (x *ClusterStatus) GetChartVersion() string

func (*ClusterStatus) GetChecks

func (x *ClusterStatus) GetChecks() []*StatusCheck

func (*ClusterStatus) GetK8SVersion

func (x *ClusterStatus) GetK8SVersion() string

func (*ClusterStatus) GetName

func (x *ClusterStatus) GetName() string

func (*ClusterStatus) GetNamespace added in v1.2.0

func (x *ClusterStatus) GetNamespace() string

func (*ClusterStatus) GetProviderId added in v1.2.0

func (x *ClusterStatus) GetProviderId() string

func (*ClusterStatus) GetRegion

func (x *ClusterStatus) GetRegion() string

func (*ClusterStatus) GetReleaseName added in v1.2.0

func (x *ClusterStatus) GetReleaseName() string

func (*ClusterStatus) GetScrapeConfig

func (x *ClusterStatus) GetScrapeConfig() string

func (*ClusterStatus) GetState

func (x *ClusterStatus) GetState() StatusType

func (*ClusterStatus) GetValidatorVersion

func (x *ClusterStatus) GetValidatorVersion() string

func (*ClusterStatus) ProtoMessage

func (*ClusterStatus) ProtoMessage()

func (*ClusterStatus) ProtoReflect

func (x *ClusterStatus) ProtoReflect() protoreflect.Message

func (*ClusterStatus) Reset

func (x *ClusterStatus) Reset()

func (*ClusterStatus) String

func (x *ClusterStatus) String() string

type StatusCheck

type StatusCheck struct {
	Name    string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Passing bool   `protobuf:"varint,2,opt,name=passing,proto3" json:"passing,omitempty"`
	Error   string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*StatusCheck) Descriptor deprecated

func (*StatusCheck) Descriptor() ([]byte, []int)

Deprecated: Use StatusCheck.ProtoReflect.Descriptor instead.

func (*StatusCheck) GetError

func (x *StatusCheck) GetError() string

func (*StatusCheck) GetName

func (x *StatusCheck) GetName() string

func (*StatusCheck) GetPassing

func (x *StatusCheck) GetPassing() bool

func (*StatusCheck) ProtoMessage

func (*StatusCheck) ProtoMessage()

func (*StatusCheck) ProtoReflect

func (x *StatusCheck) ProtoReflect() protoreflect.Message

func (*StatusCheck) Reset

func (x *StatusCheck) Reset()

func (*StatusCheck) String

func (x *StatusCheck) String() string

type StatusType

type StatusType int32
const (
	StatusType_STATUS_TYPE_UNSPECIFIED  StatusType = 0
	StatusType_STATUS_TYPE_INIT_STARTED StatusType = 1
	StatusType_STATUS_TYPE_INIT_OK      StatusType = 2
	StatusType_STATUS_TYPE_INIT_FAILED  StatusType = 3
	StatusType_STATUS_TYPE_POD_STARTED  StatusType = 4
	StatusType_STATUS_TYPE_POD_STOPPING StatusType = 5
)

func (StatusType) Descriptor

func (StatusType) Descriptor() protoreflect.EnumDescriptor

func (StatusType) Enum

func (x StatusType) Enum() *StatusType

func (StatusType) EnumDescriptor deprecated

func (StatusType) EnumDescriptor() ([]byte, []int)

Deprecated: Use StatusType.Descriptor instead.

func (StatusType) Number

func (x StatusType) Number() protoreflect.EnumNumber

func (StatusType) String

func (x StatusType) String() string

func (StatusType) Type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL