utils

package
v0.0.0-...-e6acfc1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

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 (
	// StatusConfigMapName is the name of ConfigMap with status.
	StatusConfigMapName = "cluster-autoscaler-status"
	// ConfigMapLastUpdatedKey is the name of annotation informing about status ConfigMap last update.
	ConfigMapLastUpdatedKey = "cluster-autoscaler.kubernetes.io/last-updated"
)

Variables

This section is empty.

Functions

func DeleteStatusConfigMap

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

DeleteStatusConfigMap deletes status configmap

func WriteStatusConfigMap

func WriteStatusConfigMap(kubeClient kube_client.Interface, namespace string, msg string, logRecorder *LogEventRecorder) (*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 successfull logRecorder's internal reference will be updated.

Types

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) (*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 record 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 record 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