metacache

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: Apache-2.0 Imports: 10 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MetaCache

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

MetaCache stores metadata and info of pod, node, pool, subnuma etc. as a cache, and synchronizes data to sysadvisor state file. It is thread-safe to read and write. Deep copy logic is performed during accessing metacache entries instead of directly return pointer of each struct to avoid mis-overwrite.

func NewMetaCache

func NewMetaCache(conf *config.Configuration, metricsFetcher metric.MetricsFetcher) (*MetaCache, error)

NewMetaCache returns the single instance of MetaCache

func (*MetaCache) AddContainer

func (mc *MetaCache) AddContainer(podUID string, containerName string, containerInfo *types.ContainerInfo) error

AddContainer adds a container keyed by pod uid and container name. For repeatedly added container, only mutable meta data will be updated, i.e. request quantity changed by vpa

func (*MetaCache) DeleteContainer

func (mc *MetaCache) DeleteContainer(podUID string, containerName string) error

DeleteContainer deletes a ContainerInfo keyed by pod uid and container name

func (*MetaCache) DeletePool

func (mc *MetaCache) DeletePool(poolName string) error

DeletePool deletes a PoolInfo keyed by pool name

func (*MetaCache) GCPoolEntries

func (mc *MetaCache) GCPoolEntries(livingPoolNameSet map[string]struct{}) error

GCPoolEntries deletes GCPoolEntries not existing on node

func (*MetaCache) GetContainerInfo

func (mc *MetaCache) GetContainerInfo(podUID string, containerName string) (*types.ContainerInfo, bool)

GetContainerInfo returns a ContainerInfo copy keyed by pod uid and container name

func (*MetaCache) GetContainerMetric

func (mc *MetaCache) GetContainerMetric(podUID string, containerName string, metricName string) (float64, error)

GetContainerMetric returns the metric value of a container

func (*MetaCache) GetPoolInfo

func (mc *MetaCache) GetPoolInfo(poolName string) (*types.PoolInfo, bool)

GetPoolInfo returns a PoolInfo copy by pool name

func (*MetaCache) RangeAndUpdateContainer

func (mc *MetaCache) RangeAndUpdateContainer(f func(podUID string, containerName string, containerInfo *types.ContainerInfo) bool)

RangeAndUpdateContainer applies a function to every podUID, containerName, containerInfo set. Not recommended to use if RangeContainer satisfies the requirement.

func (*MetaCache) RangeContainer

func (mc *MetaCache) RangeContainer(f func(podUID string, containerName string, containerInfo *types.ContainerInfo) bool)

RangeContainer applies a function to every podUID, containerName, containerInfo set. Deep copy logic is applied so that pod and container entries will not be overwritten.

func (*MetaCache) RemovePod

func (mc *MetaCache) RemovePod(podUID string) error

RemovePod deletes a PodInfo keyed by pod uid. Repeatedly remove will be ignored.

func (*MetaCache) SetContainerInfo

func (mc *MetaCache) SetContainerInfo(podUID string, containerName string, containerInfo *types.ContainerInfo) error

SetContainerInfo updates ContainerInfo keyed by pod uid and container name

func (*MetaCache) SetPoolInfo

func (mc *MetaCache) SetPoolInfo(poolName string, poolInfo *types.PoolInfo) error

SetPoolInfo stores a PoolInfo by pool name

type MetaCacheCheckpoint

type MetaCacheCheckpoint struct {
	PodEntries  types.PodEntries  `json:"pod_entries"`
	PoolEntries types.PoolEntries `json:"pool_entries"`
	Checksum    checksum.Checksum `json:"checksum"`
}

func NewMetaCacheCheckpoint

func NewMetaCacheCheckpoint() *MetaCacheCheckpoint

func (*MetaCacheCheckpoint) MarshalCheckpoint

func (cp *MetaCacheCheckpoint) MarshalCheckpoint() ([]byte, error)

MarshalCheckpoint returns marshalled checkpoint

func (*MetaCacheCheckpoint) UnmarshalCheckpoint

func (cp *MetaCacheCheckpoint) UnmarshalCheckpoint(blob []byte) error

UnmarshalCheckpoint tries to unmarshal passed bytes to checkpoint

func (*MetaCacheCheckpoint) VerifyChecksum

func (cp *MetaCacheCheckpoint) VerifyChecksum() error

VerifyChecksum verifies that current checksum of checkpoint is valid

Jump to

Keyboard shortcuts

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