base

package
v0.0.0-...-a2e9de6 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: Apache-2.0 Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// EveVirtTypeFile contains the virtualization type, ie kvm, xen or kubevirt
	EveVirtTypeFile = "/run/eve-hv-type"
	// KubeAppNameMaxLen limits the length of the app name for Kubernetes.
	// This also includes the appended UUID prefix.
	KubeAppNameMaxLen = 32
	// KubeAppNameUUIDSuffixLen : number of characters taken from the app UUID and appended
	// to the app name for Kubernetes (to avoid name collisions between apps of the same
	// DisplayName, see GetAppKubeName).
	KubeAppNameUUIDSuffixLen = 5
	// VMIPodNamePrefix : prefix added to name of every pod created to run VM.
	VMIPodNamePrefix = "virt-launcher-"
	// InstallOptionEtcdSizeGB grub option at install time.  Size of etcd volume in GB.
	InstallOptionEtcdSizeGB = "eve_install_kubevirt_etcd_sizeGB"
	// DefaultEtcdSizeGB default for InstallOptionEtcdSizeGB
	DefaultEtcdSizeGB uint32 = 10
	// EtcdVolBlockSizeBytes is the block size for the etcd volume
	EtcdVolBlockSizeBytes = uint64(4 * 1024)
)
View Source
const (
	// WatchdogFileDir is the dir to add .touch files for watchdog to monitor
	WatchdogFileDir = "/run/watchdog/file"
	// WatchdogPidDir is the dir to add .pid files for watchdog to monitor
	WatchdogPidDir = "/run/watchdog/pid"
)

Variables

This section is empty.

Functions

func DeleteLogObject

func DeleteLogObject(logBase *LogObject, key string)

DeleteLogObject : Delete log object from internal map logBase must be the same object as for calls to EnsureLogObject and NewLogObject

func GetAppKubeName

func GetAppKubeName(displayName string, uuid uuid.UUID) string

GetAppKubeName returns name of the application used inside Kubernetes (for Pod or VMI).

func GetVMINameFromVirtLauncher

func GetVMINameFromVirtLauncher(podName string) (vmiName string, isVirtLauncher bool)

GetVMINameFromVirtLauncher : get VMI name from the corresponding Kubevirt launcher pod name.

func InitLogObject

func InitLogObject(logBase *LogObject, object *LogObject, objType LogObjectType, objName string, objUUID uuid.UUID, key string)

InitLogObject : Initialize an already allocated LogObject

func IsHVTypeKube

func IsHVTypeKube() bool

IsHVTypeKube - return true if the EVE image is kube cluster type.

func TouchFile

func TouchFile(log *LogObject, filename string)

TouchFile touches the given file

Types

type Command

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

Command holds the necessary data to execute command

func Exec

func Exec(log *LogObject, command string, arg ...string) *Command

Exec returns Command object

func (*Command) CombinedOutput

func (c *Command) CombinedOutput() ([]byte, error)

CombinedOutput runs the command and returns its combined standard output and standard error. Waits for the exec call to finish for `defaultTimeout` after which timeout error is returned

func (*Command) Output

func (c *Command) Output() ([]byte, error)

Output runs the command and returns its standard output. Any returned error will usually be of type *ExitError. Waits for the exec call to finish for `defaultTimeout` after which timeout error is returned

func (*Command) WithContext

func (c *Command) WithContext(ctx context.Context) *Command

WithContext set context for command

func (*Command) WithLimitedTimeout

func (c *Command) WithLimitedTimeout(timeout time.Duration) *Command

WithLimitedTimeout set custom timeout for command

func (*Command) WithUnlimitedTimeout

func (c *Command) WithUnlimitedTimeout(timeout time.Duration) *Command

WithUnlimitedTimeout set custom timeout for command not bound to any limits for when run in a separate goroutine

type LockedStringMap

type LockedStringMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewLockedStringMap

func NewLockedStringMap() *LockedStringMap

func (*LockedStringMap) Delete

func (sm *LockedStringMap) Delete(key string)

func (*LockedStringMap) Load

func (sm *LockedStringMap) Load(key string) (value interface{}, ok bool)

func (*LockedStringMap) Range

func (sm *LockedStringMap) Range(callback StrMapFunc)

func (*LockedStringMap) Store

func (sm *LockedStringMap) Store(key string, value interface{})

type LogEventType

type LogEventType string

LogEventType : Predefined object types

const (
	// UnknownType : Invalid event typ
	UnknownType LogEventType = ""
	// LogObjectEventType : Used for logging object state when a change happens
	LogObjectEventType LogEventType = "log"
	// LogRelationEventType : Used for logging the relations between created objects
	LogRelationEventType LogEventType = "relation"
)

type LogObject

type LogObject struct {
	Initialized bool
	Fields      map[string]interface{}
	// contains filtered or unexported fields
}

LogObject : Holds all key value pairs to be logged later.

func EnsureLogObject

func EnsureLogObject(logBase *LogObject, objType LogObjectType, objName string, objUUID uuid.UUID, key string) *LogObject

EnsureLogObject : Look for log object with given key or create new if we do not already have one.

func LookupLogObject

func LookupLogObject(mapKey string) *LogObject

LookupLogObject :

func NewLogObject

func NewLogObject(logBase *LogObject, objType LogObjectType, objName string, objUUID uuid.UUID, key string) *LogObject

NewLogObject : objType -> [MANDATORY] volume configuration, app configuration, app status, image etc objName -> App instance name, name of file being downloaded etc objUUID -> UUID of the object if present (App instance UUID) or Zero/uninitialized UUID if not present key -> [MANDATORY] Key used for storing internal data. This should be the same Key that your LoggableObject.Key() would return. LogObject created here and the corresponding LoggableObject are linked using this key.

func NewRelationObject

func NewRelationObject(logBase *LogObject, relationObjectType RelationObjectType,
	fromObjType LogObjectType, fromObjNameOrKey string,
	toObjType LogObjectType, toObjNameOrKey string) *LogObject

NewRelationObject : Creates a relation object. Supposed to be ephemeral and not retained for long. Create a new object every time a new relation needs to be expressed. relationObjectType -> add a relation or delete an existing relation fromObjType -> Type of the source point of relation fromObjName -> Name of the source point of relation toObjType -> Type of the destination point of relation toObjName -> Name of the destination point of relation

func NewSourceLogObject

func NewSourceLogObject(logger *logrus.Logger, agentName string, agentPid int) *LogObject

NewSourceLogObject : create an object with agentName and agentPid Since there might be multiple calls to this for the same agent we check for an existing one for the agentName

func (*LogObject) AddCompositeField

func (object *LogObject) AddCompositeField(key string, value interface{}) (*LogObject, error)

AddCompositeField : Add a structure/map to be logged

func (*LogObject) AddField

func (object *LogObject) AddField(key string, value interface{}) *LogObject

AddField : Add a key value pair to be logged

func (*LogObject) AddFields

func (object *LogObject) AddFields(fields map[string]interface{}) *LogObject

AddFields : Values of exiting keys in the object will be overwritten with new values passed

func (*LogObject) Clone

func (object *LogObject) Clone() *LogObject

Clone : Create a clone from an existing Log object

func (*LogObject) CloneAndAddCompositeField

func (object *LogObject) CloneAndAddCompositeField(key string, value interface{}) *LogObject

CloneAndAddCompositeField : Add composite structure to a cloned log object

func (*LogObject) CloneAndAddField

func (object *LogObject) CloneAndAddField(key string, value interface{}) *LogObject

CloneAndAddField : Add key value pair to a cloned log object

func (*LogObject) CloneAndAddFields

func (object *LogObject) CloneAndAddFields(fields map[string]interface{}) *LogObject

CloneAndAddFields : Add additional fields to a cloned log object

func (*LogObject) CloneAndMerge

func (object *LogObject) CloneAndMerge(source *LogObject) *LogObject

CloneAndMerge : Merge source into a cloned log object

func (*LogObject) Error

func (object *LogObject) Error(args ...interface{})

Error :

func (*LogObject) Errorf

func (object *LogObject) Errorf(format string, args ...interface{})

Errorf :

func (*LogObject) Errorln

func (object *LogObject) Errorln(args ...interface{})

Errorln :

func (*LogObject) Fatal

func (object *LogObject) Fatal(args ...interface{})

Fatal :

func (*LogObject) Fatalf

func (object *LogObject) Fatalf(format string, args ...interface{})

Fatalf :

func (*LogObject) Fatalln

func (object *LogObject) Fatalln(args ...interface{})

Fatalln :

func (*LogObject) Function

func (object *LogObject) Function(args ...interface{})

Function :

func (*LogObject) Functionf

func (object *LogObject) Functionf(format string, args ...interface{})

Functionf :

func (*LogObject) Functionln

func (object *LogObject) Functionln(args ...interface{})

Functionln :

func (*LogObject) Merge

func (object *LogObject) Merge(source *LogObject) *LogObject

Merge : Values of existing fields in destination object will be overwritten with values from source object.

func (*LogObject) Metric

func (object *LogObject) Metric(args ...interface{})

Metric :

func (*LogObject) Metricf

func (object *LogObject) Metricf(format string, args ...interface{})

Metricf :

func (*LogObject) Metricln

func (object *LogObject) Metricln(args ...interface{})

Metricln :

func (*LogObject) Notice

func (object *LogObject) Notice(args ...interface{})

Notice :

func (*LogObject) Noticef

func (object *LogObject) Noticef(format string, args ...interface{})

Noticef :

func (*LogObject) Noticeln

func (object *LogObject) Noticeln(args ...interface{})

Noticeln :

func (*LogObject) Panic

func (object *LogObject) Panic(args ...interface{})

Panic :

func (*LogObject) Panicf

func (object *LogObject) Panicf(format string, args ...interface{})

Panicf :

func (*LogObject) Panicln

func (object *LogObject) Panicln(args ...interface{})

Panicln :

func (*LogObject) Trace

func (object *LogObject) Trace(args ...interface{})

Trace :

func (*LogObject) Tracef

func (object *LogObject) Tracef(format string, args ...interface{})

Tracef :

func (*LogObject) Traceln

func (object *LogObject) Traceln(args ...interface{})

Traceln :

func (*LogObject) Warn

func (object *LogObject) Warn(args ...interface{})

Warn :

func (*LogObject) Warnf

func (object *LogObject) Warnf(format string, args ...interface{})

Warnf :

func (*LogObject) Warning

func (object *LogObject) Warning(args ...interface{})

Warning :

func (*LogObject) Warningf

func (object *LogObject) Warningf(format string, args ...interface{})

Warningf :

func (*LogObject) Warningln

func (object *LogObject) Warningln(args ...interface{})

Warningln :

func (*LogObject) Warnln

func (object *LogObject) Warnln(args ...interface{})

Warnln :

type LogObjectType

type LogObjectType string

LogObjectType :

const (
	// UnknownLogType : Invalid log type
	UnknownLogType LogObjectType = ""
	// ImageLogType :
	ImageLogType LogObjectType = "image"
	// AppInstanceStatusLogType :
	AppInstanceStatusLogType LogObjectType = "app_instance_status"
	// AppInstanceConfigLogType :
	AppInstanceConfigLogType LogObjectType = "app_instance_config"
	// AppNetworkStatusLogType :
	AppNetworkStatusLogType LogObjectType = "app_network_status"
	// AppNetworkConfigLogType :
	AppNetworkConfigLogType LogObjectType = "app_network_config"
	// DatastoreConfigLogType :
	DatastoreConfigLogType LogObjectType = "datastore_config"
	// DomainConfigLogType :
	DomainConfigLogType LogObjectType = "domain_config"
	// DomainStatusLogType :
	DomainStatusLogType LogObjectType = "domain_status"
	// DomainMetricLogType :
	DomainMetricLogType LogObjectType = "domain_metric"
	// BaseOsConfigLogType :
	BaseOsConfigLogType LogObjectType = "baseos_config"
	// BaseOsStatusLogType :
	BaseOsStatusLogType LogObjectType = "baseos_status"
	// NodeAgentStatusLogType :
	NodeAgentStatusLogType LogObjectType = "nodeagent_status"
	// ZedAgentStatusLogType :
	ZedAgentStatusLogType LogObjectType = "zedagent_status"
	// ZbootConfigLogType :
	ZbootConfigLogType LogObjectType = "zboot_config"
	// ZbootStatusLogType :
	ZbootStatusLogType LogObjectType = "zboot_status"
	// DownloaderConfigLogType :
	DownloaderConfigLogType LogObjectType = "downloader_config"
	// DownloaderStatusLogType :
	DownloaderStatusLogType LogObjectType = "downloader_status"
	// ResolveConfigLogType :
	ResolveConfigLogType LogObjectType = "resolve_config"
	// ResolveStatusLogType :
	ResolveStatusLogType LogObjectType = "resolve_status"
	// VerifyImageConfigLogType :
	VerifyImageConfigLogType LogObjectType = "verifyimage_config"
	// VerifyImageStatusLogType :
	VerifyImageStatusLogType LogObjectType = "verifyimage_status"
	// ContentTreeConfigLogType :
	ContentTreeConfigLogType LogObjectType = "contenttree_config"
	// ContentTreeStatusLogType :
	ContentTreeStatusLogType LogObjectType = "contenttree_status"
	// DevicePortConfig : object being logged
	DevicePortConfigLogType LogObjectType = "deviceport_config"
	// DevicePortConfigList :
	DevicePortConfigListLogType LogObjectType = "deviceportconfig_list"
	// DeviceNetworkStatus :
	DeviceNetworkStatusLogType LogObjectType = "devicenetwork_status"
	// BlobStatusType:
	BlobStatusLogType LogObjectType = "blob_status"
	// VolumeConfigLogType:
	VolumeConfigLogType LogObjectType = "volume_config"
	// VolumeStatusLogType:
	VolumeStatusLogType LogObjectType = "volume_status"
	// VolumeRefConfigLogType:
	VolumeRefConfigLogType LogObjectType = "volume_ref_config"
	// VolumeRefStatusLogType:
	VolumeRefStatusLogType LogObjectType = "volume_ref_status"
	// VolumeCreatePendingLogType:
	VolumeCreatePendingLogType LogObjectType = "volume_create_pending"
	// ServiceInitType:
	ServiceInitLogType LogObjectType = "service_init"
	// AppAndImageToHashLogType:
	AppAndImageToHashLogType LogObjectType = "app_and_image_to_hash"
	// AppContainerMetricsLogType:
	AppContainerMetricsLogType LogObjectType = "app_container_metric"
	// AssignableAdaptersLogType:
	AssignableAdaptersLogType LogObjectType = "assignable_adapters"
	// PhysicalIOAdapterListLogType:
	PhysicalIOAdapterListLogType LogObjectType = "physical_io_adapter_list"
	// AttestNonceLogType:
	AttestNonceLogType LogObjectType = "attest_nonce"
	// AttestQuoteLogType:
	AttestQuoteLogType LogObjectType = "attest_quote"
	// VaultStatusLogType:
	VaultStatusLogType LogObjectType = "vault_status"
	// CipherBlockStatusLogType:
	CipherBlockStatusLogType LogObjectType = "cipher_block_status"
	// CipherContextLogType:
	CipherContextLogType LogObjectType = "cipher_context"
	// CipherMetricsLogType:
	CipherMetricsLogType LogObjectType = "cipher_metric"
	// ControllerCertLogType:
	ControllerCertLogType LogObjectType = "controller_cert"
	// EdgeNodeCertLogType:
	EdgeNodeCertLogType LogObjectType = "edge_node_cert"
	// HostMemoryLogType:
	HostMemoryLogType LogObjectType = "host_memory"
	// IPFlowLogType:
	IPFlowLogType LogObjectType = "ip_flow"
	// VifIPTrigLogType:
	VifIPTrigLogType LogObjectType = "vif_ip_trig"
	// OnboardingStatusLogType:
	OnboardingStatusLogType LogObjectType = "onboarding_status"
	// NetworkInstanceConfigLogType:
	NetworkInstanceConfigLogType LogObjectType = "network_instance_config"
	// NetworkInstanceStatusLogType:
	NetworkInstanceStatusLogType LogObjectType = "network_instance_status"
	// NetworkInstanceMetricsLogType:
	NetworkInstanceMetricsLogType LogObjectType = "network_instance_metrics"
	// NetworkMetricsLogType:
	NetworkMetricsLogType LogObjectType = "network_metrics"
	// WwanConfigLogType:
	WwanConfigLogType LogObjectType = "wwan_config"
	// WwanStatusLogType:
	WwanStatusLogType LogObjectType = "wwan_status"
	// WwanMetricsLogType:
	WwanMetricsLogType LogObjectType = "wwan_metrics"
	// WwanLocationInfoLogType:
	WwanLocationInfoLogType LogObjectType = "wwan_location_info"
	// NetworkXObjectConfigLogType:
	NetworkXObjectConfigLogType LogObjectType = "network_x_object"
	// UUIDToNumLogType:
	UUIDToNumLogType LogObjectType = "uuid_to_num"
	// DiskMetricType:
	DiskMetricType LogObjectType = "disk_metric"
	// AppDiskMetricType:
	AppDiskMetricType LogObjectType = "app_disk_metric"
	// ProcessMetricLogType:
	ProcessMetricLogType LogObjectType = "process_metric"
	// SigUSR1StacksType:
	SigUSR1StacksType LogObjectType = "sigusr1_stacks"
	// FatalStacksType:
	FatalStacksType LogObjectType = "fatal_stacks"
	// MemoryNotificationType
	MemoryNotificationType = "memory_notification"
	// DiskNotificationType
	DiskNotificationType = "disk_notification"
	// AppInterfaceToNumLogType
	AppInterfaceToNumLogType LogObjectType = "app_interface_to_num"
	// EncryptedVaultKeyFromDeviceLogType:
	EncryptedVaultKeyFromDeviceLogType LogObjectType = "encrypted_vault_key_from_device"
	// EncryptedVaultKeyFromControllerLogType:
	EncryptedVaultKeyFromControllerLogType LogObjectType = "encrypted_vault_key_from_controller"
	// CachedResolvedIPsLogType:
	CachedResolvedIPsLogType LogObjectType = "cached_resolved_ips"
	// AppMACGeneratorLogType : type for AppMACGenerator log entries
	AppMACGeneratorLogType LogObjectType = "app_mac_generator"
)

The following is NOT an extensive list. Intent is to create a reference list for engineers to get an idea of its usage.

type LoggableObject

type LoggableObject interface {
	LogKey() string
	LogCreate(logBase *LogObject)
	LogModify(logBase *LogObject, old interface{})
	LogDelete(logBase *LogObject)
}

LoggableObject :

type LogrusWrapper

type LogrusWrapper struct {
	Log *LogObject
}

LogrusWrapper wraps LogObject to implement the same interface as the widely used Sirupsen/Logrus (see https://github.com/sirupsen/logrus) This may allow to use LogObject in libraries outside of pillar. However, only methods with formatted output are wrapped for now.

func (*LogrusWrapper) Debugf

func (w *LogrusWrapper) Debugf(format string, args ...interface{})

Debugf : formatted log message with info useful for debugging.

func (*LogrusWrapper) Errorf

func (w *LogrusWrapper) Errorf(format string, args ...interface{})

Errorf : formatted log message with an error.

func (*LogrusWrapper) Fatalf

func (w *LogrusWrapper) Fatalf(format string, args ...interface{})

Fatalf : formatted log message with an error, ending with a call to os.Exit() with a non-zero return value.

func (*LogrusWrapper) Infof

func (w *LogrusWrapper) Infof(format string, args ...interface{})

Infof : formatted log message with a general info about what's going on inside the application.

func (*LogrusWrapper) Panicf

func (w *LogrusWrapper) Panicf(format string, args ...interface{})

Panicf : formatted log message with an error, raising a panic.

func (*LogrusWrapper) Tracef

func (w *LogrusWrapper) Tracef(format string, args ...interface{})

Tracef : formatted log message with info useful for finer-grained debugging.

func (*LogrusWrapper) Warningf

func (w *LogrusWrapper) Warningf(format string, args ...interface{})

Warningf : formatted log message with a warning.

type RelationObjectType

type RelationObjectType string

RelationObjectType :

const (
	// UnknownRelationType : Invalid relation type
	UnknownRelationType RelationObjectType = ""
	// AddRelationType :
	AddRelationType RelationObjectType = "add_relation"
	// DeleteRelationType :
	DeleteRelationType RelationObjectType = "delete_relation"
)

type StrMapFunc

type StrMapFunc func(key string, val interface{}) bool

StrMapFunc :

Jump to

Keyboard shortcuts

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