utils

package
v0.0.0-...-da31dff Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 44

Documentation

Index

Constants

View Source
const (
	// DefaultLogCollectorMaxItems defines default maximum size of LogCollector.
	DefaultLogCollectorMaxItems = 50
	// DefaultLogCollectorItemLifetime is the default time after which LogItem will be removed from LogCollector.
	DefaultLogCollectorItemLifetime = 15 * time.Minute
)
View Source
const (
	// CloudProviderNodeInstancesCacheRefreshInterval is the interval between nodegroup instances cache refreshes.
	CloudProviderNodeInstancesCacheRefreshInterval = 2 * time.Minute
	// CloudProviderNodeInstancesCacheEntryFreshnessThreshold is the duration when cache entry is fresh.
	CloudProviderNodeInstancesCacheEntryFreshnessThreshold = 5 * time.Minute
)
View Source
const (
	// ConfigMapLastUpdatedKey is the name of annotation informing about status ConfigMap last update.
	ConfigMapLastUpdatedKey = "cluster-autoscaler.kubernetes.io/last-updated"
	// ConfigMapLastUpdateFormat it the timestamp format used for last update annotation in status ConfigMap
	ConfigMapLastUpdateFormat = "2006-01-02 15:04:05.999999999 -0700 MST"
)

Variables

This section is empty.

Functions

func DeleteStatusConfigMap

func DeleteStatusConfigMap(kubeClient kube_client.Interface, namespace string, statusConfigMapName string) error

DeleteStatusConfigMap deletes status configmap

func EmptyClusterAutoscalerStatus

func EmptyClusterAutoscalerStatus() *api.ClusterAutoscalerStatus

EmptyClusterAutoscalerStatus returns empty status for ClusterAutoscalerStatus when it is being initialized.

func WriteStatusConfigMap

func WriteStatusConfigMap(kubeClient kube_client.Interface, namespace string, status api.ClusterAutoscalerStatus, logRecorder *LogEventRecorder, statusConfigMapName string, currentTime time.Time) (*apiv1.ConfigMap, error)

WriteStatusConfigMap writes updates status ConfigMap with a given message or creates a new ConfigMap if it doesn't exist. If logRecorder is passed and configmap update is successful logRecorder's internal reference will be updated.

Types

type CloudProviderNodeInstancesCache

type CloudProviderNodeInstancesCache struct {
	sync.Mutex
	// contains filtered or unexported fields
}

CloudProviderNodeInstancesCache caches cloud provider node instances.

func NewCloudProviderNodeInstancesCache

func NewCloudProviderNodeInstancesCache(cloudProvider cloudprovider.CloudProvider) *CloudProviderNodeInstancesCache

NewCloudProviderNodeInstancesCache creates new cache instance.

func (*CloudProviderNodeInstancesCache) GetCloudProviderNodeInstances

func (cache *CloudProviderNodeInstancesCache) GetCloudProviderNodeInstances() (map[string][]cloudprovider.Instance, error)

GetCloudProviderNodeInstances returns cloud provider node instances for all node groups returned by cloud provider.

func (*CloudProviderNodeInstancesCache) GetCloudProviderNodeInstancesForNodeGroup

func (cache *CloudProviderNodeInstancesCache) GetCloudProviderNodeInstancesForNodeGroup(nodeGroup cloudprovider.NodeGroup) ([]cloudprovider.Instance, error)

GetCloudProviderNodeInstancesForNodeGroup returns cloud provider node instances for the given node group.

func (*CloudProviderNodeInstancesCache) InvalidateCacheEntry

func (cache *CloudProviderNodeInstancesCache) InvalidateCacheEntry(nodeGroup cloudprovider.NodeGroup)

InvalidateCacheEntry removes entry for the given node group from cache.

func (*CloudProviderNodeInstancesCache) Refresh

func (cache *CloudProviderNodeInstancesCache) Refresh()

Refresh refreshes cache.

func (*CloudProviderNodeInstancesCache) Start

func (cache *CloudProviderNodeInstancesCache) Start(interrupt chan struct{})

Start starts components running in background.

type LogCollector

type LogCollector struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LogCollector keeps recent log events. It is automatically truncated on each access based on predefined set of conditions.

func NewLogCollector

func NewLogCollector() *LogCollector

NewLogCollector creates new LogCollector.

func (*LogCollector) GetLogs

func (lc *LogCollector) GetLogs() []LogItem

GetLogs returns a copy of messages in log. This is an actual copy, so it will not reflect any future changes in log.

func (*LogCollector) Log

func (lc *LogCollector) Log(msg string, level LogLevel)

Log logs a single provided message in LogCollector.

type LogEventRecorder

type LogEventRecorder struct {
	// contains filtered or unexported fields
}

LogEventRecorder records events on some top-level object, to give user (without access to logs) a view of most important CA actions.

func NewStatusMapRecorder

func NewStatusMapRecorder(kubeClient kube_client.Interface, namespace string, recorder record.EventRecorder, active bool, statusConfigMapName string) (*LogEventRecorder, error)

NewStatusMapRecorder creates a LogEventRecorder creating events on status configmap. If the configmap doesn't exist it will be created (with 'Initializing' status). If active == false the map will not be created and no events will be recorded.

func (*LogEventRecorder) Event

func (ler *LogEventRecorder) Event(eventtype, reason, message string)

Event records an event on underlying object. This does nothing if the underlying object is not set.

func (*LogEventRecorder) Eventf

func (ler *LogEventRecorder) Eventf(eventtype, reason, message string, args ...interface{})

Eventf records an event on underlying object. This does nothing if the underlying object is not set.

type LogItem

type LogItem struct {
	// Log is the logged message body.
	Log string
	// Level describes log severity.
	Level LogLevel
	// Timestamp when the Log was created.
	Timestamp time.Time
}

LogItem is a single entry in log managed by LogCollector.

type LogLevel

type LogLevel string

LogLevel describes severity of log entry.

const (
	// Debug log level.
	Debug LogLevel = "DEBUG"
	// Info log level.
	Info LogLevel = "INFO"
	// Warning log level.
	Warning LogLevel = "WARNING"
	// Error log level.
	Error LogLevel = "ERROR"
)

Jump to

Keyboard shortcuts

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