storage

package
v0.0.0-...-c8e4b7a Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UidDataKey is the key used in config maps to store the UID.
	UidDataKey = "uid"
	// ProviderDataKey is the key used in config maps to store the Provider
	// UID which we use to ensure unique firewalls.
	ProviderDataKey = "provider-uid"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIServerConfigMapStore

type APIServerConfigMapStore struct {
	ConfigMapStore
	// contains filtered or unexported fields
}

APIServerConfigMapStore only services Add and GetByKey from apiserver. TODO: Implement all the other store methods and make this a write through cache.

func (*APIServerConfigMapStore) Add

func (a *APIServerConfigMapStore) Add(obj interface{}) error

Add adds the given config map to the apiserver's store.

func (*APIServerConfigMapStore) Delete

func (a *APIServerConfigMapStore) Delete(obj interface{}) error

Delete deletes the existing config map object.

func (*APIServerConfigMapStore) GetByKey

func (a *APIServerConfigMapStore) GetByKey(key string) (item interface{}, exists bool, err error)

GetByKey returns the config map for a given key. The key must take the form namespace/name.

func (*APIServerConfigMapStore) Update

func (a *APIServerConfigMapStore) Update(obj interface{}) error

Update updates the existing config map object.

type CloudListingPool

type CloudListingPool struct {

	// The pool that is re-populated via re-list from cloud, and written to
	// from controller
	*InMemoryPool
	// contains filtered or unexported fields
}

CloudListingPool wraps InMemoryPool but relists from the cloud periodically.

func NewCloudListingPool

func NewCloudListingPool(k keyFunc, lister cloudLister, relistPeriod time.Duration) *CloudListingPool

NewCloudListingPool replenishes the InMemoryPool through a background goroutine that lists from the given cloudLister.

func (*CloudListingPool) Add

func (c *CloudListingPool) Add(key string, obj interface{})

Add simply adds to the underlying pool.

func (*CloudListingPool) Delete

func (c *CloudListingPool) Delete(key string)

Delete just deletes from underlying pool.

func (*CloudListingPool) ReplenishPool

func (c *CloudListingPool) ReplenishPool()

ReplenishPool lists through the cloudLister and inserts into the pool. This is especially useful in scenarios like deleting an Ingress while the controller is restarting. As long as the resource exists in the shared memory pool, it is visible to the caller and they can take corrective actions, eg: backend pool deletes backends with non-matching node ports in its sync method.

func (*CloudListingPool) Snapshot

func (c *CloudListingPool) Snapshot() map[string]interface{}

Snapshot just snapshots the underlying pool.

type ConfigMapStore

type ConfigMapStore interface {
	cache.Store
}

ConfigMapStore wraps the store interface. Implementations usually persist contents of the store transparently.

func NewConfigMapStore

func NewConfigMapStore(c kubernetes.Interface) ConfigMapStore

NewConfigMapStore returns a config map store capable of persisting updates to apiserver.

type ConfigMapVault

type ConfigMapVault struct {
	ConfigMapStore cache.Store
	// contains filtered or unexported fields
}

ConfigMapVault stores cluster UIDs in config maps. It's a layer on top of ConfigMapStore that just implements the utils.uidVault interface.

func NewConfigMapVault

func NewConfigMapVault(c kubernetes.Interface, uidNs, uidConfigMapName string) *ConfigMapVault

NewConfigMapVault creates a config map client. This client is essentially meant to abstract out the details of configmaps and the API, and just store/retrieve a single value, the cluster uid.

func NewFakeConfigMapVault

func NewFakeConfigMapVault(ns, name string) *ConfigMapVault

NewFakeConfigMapVault is an implementation of the ConfigMapStore that doesn't persist configmaps. Only used in testing.

func (*ConfigMapVault) Delete

func (c *ConfigMapVault) Delete() error

Delete deletes the ConfigMapStore.

func (*ConfigMapVault) Get

func (c *ConfigMapVault) Get(key string) (string, bool, error)

Get retrieves the value associated to the provided 'key' from the cluster config map. If this method returns an error, it's guaranteed to be apiserver flake. If the error is a not found error it sets the boolean to false and returns and error of nil instead.

func (*ConfigMapVault) Put

func (c *ConfigMapVault) Put(key, val string) error

Put inserts a key/value pair in the cluster config map. If the key already exists, the value provided is stored.

type InMemoryPool

type InMemoryPool struct {
	cache.ThreadSafeStore
}

InMemoryPool is used as a cache for cluster resource pools.

func NewInMemoryPool

func NewInMemoryPool() *InMemoryPool

NewInMemoryPool creates an InMemoryPool.

func (*InMemoryPool) Snapshot

func (p *InMemoryPool) Snapshot() map[string]interface{}

Snapshot returns a read only copy of the k:v pairs in the store. Caller beware: Violates traditional snapshot guarantees.

type Snapshotter

type Snapshotter interface {
	Snapshot() map[string]interface{}
	cache.ThreadSafeStore
}

Snapshotter is an interface capable of providing a consistent snapshot of the underlying storage implementation of a pool. It does not guarantee thread safety of snapshots, so they should be treated as read only unless the implementation specifies otherwise.

Jump to

Keyboard shortcuts

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