dsstore

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoDaemonSet error = errors.New("No daemon set found")

Functions

func IsNotExist

func IsNotExist(err error) bool

Types

type AuditLogStore

type AuditLogStore interface {
	Create(ctx context.Context, eventType audit.EventType, eventDetails json.RawMessage) error
}

type AuditingStore

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

AuditingStore is a wrapper around a ConsulStore that will produce audit logs for the actions taken.

func NewAuditingStore

func NewAuditingStore(innerStore *ConsulStore, auditLogStore AuditLogStore) AuditingStore

func (AuditingStore) Create

func (a AuditingStore) Create(
	ctx context.Context,
	manifest manifest.Manifest,
	minHealth int,
	name fields.ClusterName,
	nodeSelector klabels.Selector,
	podID types.PodID,
	timeout time.Duration,
	user string,
) (fields.DaemonSet, error)

func (AuditingStore) Delete

func (a AuditingStore) Delete(
	ctx context.Context,
	id fields.ID,
	user string,
) error

func (AuditingStore) Disable

func (a AuditingStore) Disable(
	ctx context.Context,
	id fields.ID,
	user string,
) (fields.DaemonSet, error)

func (AuditingStore) Enable

func (a AuditingStore) Enable(
	ctx context.Context,
	id fields.ID,
	user string,
) (fields.DaemonSet, error)

func (AuditingStore) UpdateManifest

func (a AuditingStore) UpdateManifest(
	ctx context.Context,
	id fields.ID,
	manifest manifest.Manifest,
	user string,
) (fields.DaemonSet, error)

func (AuditingStore) UpdateMinHealth

func (a AuditingStore) UpdateMinHealth(
	ctx context.Context,
	id fields.ID,
	minHealth int,
	user string,
) (fields.DaemonSet, error)

func (AuditingStore) UpdateNodeSelector

func (a AuditingStore) UpdateNodeSelector(
	ctx context.Context,
	id fields.ID,
	nodeSelector klabels.Selector,
	user string,
) (fields.DaemonSet, error)

func (AuditingStore) UpdateTimeout

func (a AuditingStore) UpdateTimeout(
	ctx context.Context,
	id fields.ID,
	timeout time.Duration,
	user string,
) (fields.DaemonSet, error)

type CASError

type CASError string

TODO: combine with similar CASError type in pkg/labels

func (CASError) Error

func (e CASError) Error() string

type ConsulStore

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

store represents an interface for persisting daemon set to Consul, as well as restoring daemon set from Consul.

func NewConsul

func NewConsul(client consulutil.ConsulClient, retries int, logger *logging.Logger) *ConsulStore

func (*ConsulStore) Create

func (s *ConsulStore) Create(
	ctx context.Context,
	manifest manifest.Manifest,
	minHealth int,
	name fields.ClusterName,
	nodeSelector klabels.Selector,
	podID types.PodID,
	timeout time.Duration,
) (fields.DaemonSet, error)

Create creates a daemon set with the specified manifest and selectors. The node selector is used to determine what nodes the daemon set may schedule on. The pod label set is applied to every pod the daemon set schedules.

func (*ConsulStore) Delete

func (s *ConsulStore) Delete(id fields.ID) error

Delete deletes a daemon set by ID. It does not return an error if no daemon set with the given ID exists.

func (*ConsulStore) DeleteTxn

func (s *ConsulStore) DeleteTxn(ctx context.Context, id fields.ID) error

DeleteTxn adds a deletion operation to the passed transaction for the given daemon set ID. The operation will not error if the id does not exist TODO: replace all calls of Delete with DeleteTxn

func (*ConsulStore) Disable

func (s *ConsulStore) Disable(id fields.ID) (fields.DaemonSet, error)

Disable sets a flag on the daemon set to prevent it from operating.

func (*ConsulStore) DisableTxn

func (s *ConsulStore) DisableTxn(ctx context.Context, id fields.ID) (fields.DaemonSet, error)

DisableTxn adds an operation to the passed context to disable the daemon set

func (*ConsulStore) EnableTxn

func (s *ConsulStore) EnableTxn(ctx context.Context, id fields.ID) (fields.DaemonSet, error)

EnableTxn adds an operation to the passed context to enable the daemon set

func (*ConsulStore) Get

Get retrieves a daemon set by ID. If it does not exist, it will produce an error

func (*ConsulStore) List

func (s *ConsulStore) List() ([]fields.DaemonSet, error)

func (*ConsulStore) LockForOwnership

func (s *ConsulStore) LockForOwnership(dsID fields.ID, session consul.Session) (consul.Unlocker, error)

LockForOwnership qcquires a lock on the DS that should be used by DS farm goroutines, whose job it is to carry out the intent of the DS.

func (*ConsulStore) LockForOwnershipTxn

func (s *ConsulStore) LockForOwnershipTxn(
	lockCtx context.Context,
	dsID fields.ID,
	session consul.Session,
) (consul.TxnUnlocker, error)

LockForOwnershipTxn is should be called when taking "ownership" of a daemon set. Holding the ownership lock before taking action for a daemon set is used to guarantee that no two processes are doing the same work (and potentially conflicting). This function: 1) adds the necessary consul operations to LOCK the daemon set to the transaction context `lockCtx` 2) adds the necessary consul operations to UNLOCK the daemon set to `unlockCtx` 3) adds the necessary consul operations to CHECK that the lock is held to `checkLockedCtx`. It is good practice to branch any consul transactions that will write to consul off of this transaction to make sure that the lock is still held or othwerwise roll back the transaction

func (*ConsulStore) MutateDS

func (s *ConsulStore) MutateDS(
	id fields.ID,
	mutator func(fields.DaemonSet) (fields.DaemonSet, error),
) (fields.DaemonSet, error)

MutateDS mutates the daemon set with the given id according to the passed mutator function. Any modifications to the daemon set done within the function will be applied if and only if the daemon set was not changed since the value was read (check-and-set operation used)

func (*ConsulStore) MutateDSTxn

func (s *ConsulStore) MutateDSTxn(
	ctx context.Context,
	id fields.ID,
	mutator func(fields.DaemonSet) (fields.DaemonSet, error),
) (fields.DaemonSet, error)

MutateDSTxn adds a check-and-set operation to the passed transaction to perform the mutation requested via the mutator function. TODO: replace all calls of MutateDS with this

func (*ConsulStore) Watch

func (s *ConsulStore) Watch(quitCh <-chan struct{}) <-chan WatchedDaemonSets

Watch watches dsTree for changes and returns a blocking channel where the client can read a WatchedDaemonSets object which contain changed daemon sets

func (*ConsulStore) WatchAll

func (s *ConsulStore) WatchAll(quitCh <-chan struct{}, pauseTime time.Duration) <-chan WatchedDaemonSetList

WatchAll watches dsTree for all the daemon sets and returns a blocking channel where the client can read a WatchedDaemonSetsList object which contain all of the daemon sets currently on the tree

type WatchedDaemonSetList

type WatchedDaemonSetList struct {
	DaemonSets []fields.DaemonSet
	Err        error
}

type WatchedDaemonSets

type WatchedDaemonSets struct {
	Created []*fields.DaemonSet
	Updated []*fields.DaemonSet
	Deleted []*fields.DaemonSet
	Same    []*fields.DaemonSet
	Err     error
}

Jump to

Keyboard shortcuts

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