Documentation ¶
Index ¶
- func DeleteAll(txn UpdateOperations, values KeyValuePairs)
- func NewAbortEventError(origErr error) error
- func NewFatalError(origErr error) error
- func PutAll(txn ResyncOperations, values KeyValuePairs)
- type AbortEventError
- type DBResync
- type Event
- type EventHandler
- type EventLoop
- type EventMethodType
- type ExternalConfigChange
- func (ev *ExternalConfigChange) Direction() UpdateDirectionType
- func (ev *ExternalConfigChange) Done(err error)
- func (ev *ExternalConfigChange) GetName() string
- func (ev *ExternalConfigChange) IsBlocking() bool
- func (ev *ExternalConfigChange) Method() EventMethodType
- func (ev *ExternalConfigChange) String() string
- func (ev *ExternalConfigChange) TransactionType() UpdateTransactionType
- func (ev *ExternalConfigChange) Wait() error
- type ExternalConfigResync
- type FatalError
- type HealingResync
- type HealingResyncType
- type KeyValuePairs
- type KubeStateChange
- func (ev *KubeStateChange) Direction() UpdateDirectionType
- func (ev *KubeStateChange) Done(error)
- func (ev *KubeStateChange) GetName() string
- func (ev *KubeStateChange) IsBlocking() bool
- func (ev *KubeStateChange) Method() EventMethodType
- func (ev *KubeStateChange) String() string
- func (ev *KubeStateChange) TransactionType() UpdateTransactionType
- type KubeStateData
- type ResyncOperations
- type Shutdown
- func (ev *Shutdown) Direction() UpdateDirectionType
- func (ev *Shutdown) Done(err error)
- func (ev *Shutdown) GetName() string
- func (ev *Shutdown) IsBlocking() bool
- func (ev *Shutdown) Method() EventMethodType
- func (ev *Shutdown) String() string
- func (ev *Shutdown) TransactionType() UpdateTransactionType
- func (ev *Shutdown) Wait() error
- type Transaction
- type UpdateDirectionType
- type UpdateEvent
- type UpdateOperations
- type UpdateTransactionType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DeleteAll ¶
func DeleteAll(txn UpdateOperations, values KeyValuePairs)
DeleteAll is a helper function to prepare Delete for multiple key-value pairs into a single transaction.
func NewAbortEventError ¶
NewAbortEventError is the constructor for the AbortEventError.
func NewFatalError ¶
NewFatalError is the constructor for FatalError.
func PutAll ¶
func PutAll(txn ResyncOperations, values KeyValuePairs)
PutAll is a helper function to prepare Put for multiple key-value pairs into a single transaction.
Types ¶
type AbortEventError ¶
type AbortEventError struct {
// contains filtered or unexported fields
}
AbortEventError tells controller to abort the processing of the event (and for Update/RevertOnFailure to revert the changes). The agent does not have to restart but resync should be performed as soon as possible.
func (*AbortEventError) Error ¶
func (e *AbortEventError) Error() string
Error delegates the call to the underlying error.
func (*AbortEventError) GetOriginalError ¶
func (e *AbortEventError) GetOriginalError() error
GetOriginalError returns the underlying error.
type DBResync ¶
type DBResync struct { Local bool // against local DB? KubeState KubeStateData ExternalConfig KeyValuePairs }
DBResync is a Resync Event that carries snapshot of the database for all watched Kubernetes resources and the external configuration (for vpp-agent).
type Event ¶
type Event interface { // GetName should return a string identifier, unique among the event types, // but also somewhat descriptive for humans. GetName() string // String should return a description of the event. String() string // Method tells whether the event can be reacted to by an incremental change // (Update) or if a full re-synchronization is needed (Resync, i.e. complex // change). Method() EventMethodType // IsBlocking should return true if any producer of this event ever waits // for the event result (sent using the method Done()). IsBlocking() bool // Done is used to mark the event as processed. // A specific Event implementation may use this method for example to deliver // the return value back to the send of the event. Done(error) }
Event represents something that has happened and may cause some reaction.
type EventHandler ¶
type EventHandler interface { // String identifies the handler for the Controller and in the logs. // Note: Plugins already implement Stringer. String() string // HandlesEvent is used by Controller to check if the event is being handled // by this handler. HandlesEvent(event Event) bool // Resync is called by Controller to handle event that requires full // re-synchronization. // For startup resync, resyncCount is 1. Higher counter values identify // run-time resync. Resync(event Event, kubeStateData KubeStateData, resyncCount int, txn ResyncOperations) error // Update is called by Controller to handle event that can be reacted to by // an incremental change. // <changeDescription> should be human-readable description of changes that // have to be performed (via txn or internally) - can be empty. Update(event Event, txn UpdateOperations) (changeDescription string, err error) // Revert is called to revert already executed internal changes (in the plugin // itself, not in VPP/Linux network stack) for a RevertOnFailure event that // has failed in the processing. Revert(event Event) error }
EventHandler declares methods that event handler must implement.
type EventLoop ¶
type EventLoop interface { // PushEvent adds the given event into the queue for processing. PushEvent(event Event) error }
EventLoop defines method for accessing the main event loop.
type EventMethodType ¶
type EventMethodType int
EventMethodType is either Resync or Update.
const ( // FullResync event requires to be reacted to by a full re-synchronization // (Contiv -> VPP-agent <-> SB). FullResync EventMethodType = iota // DownstreamResync triggers re-synchronization between vpp-agent and SB. // Event is fully processed by the Controller (not passed to event handlers). DownstreamResync // UpstreamResync triggers re-synchronization between Contiv and VPP-agent. // It can be used whenever it is far easier to re-build the configuration // from the scratch as opposed to calculating an incremental change. UpstreamResync // Update event can be reacted to by an incremental change. Update )
type ExternalConfigChange ¶
type ExternalConfigChange struct { Source string UpdatedKVs KeyValuePairs // contains filtered or unexported fields }
ExternalConfigChange is an Update event that represents change for one or more keys from the external configuration (for vpp-agent).
func NewExternalConfigChange ¶
func NewExternalConfigChange(source string, blocking bool) *ExternalConfigChange
NewExternalConfigChange is a constructor for ExternalConfigChange.
func (*ExternalConfigChange) Direction ¶
func (ev *ExternalConfigChange) Direction() UpdateDirectionType
Direction is Forward.
func (*ExternalConfigChange) Done ¶
func (ev *ExternalConfigChange) Done(err error)
Done propagates error to the event producer.
func (*ExternalConfigChange) GetName ¶
func (ev *ExternalConfigChange) GetName() string
GetName returns name of the ExternalConfigChange event.
func (*ExternalConfigChange) IsBlocking ¶
func (ev *ExternalConfigChange) IsBlocking() bool
IsBlocking returns what is configured in the constructor.
func (*ExternalConfigChange) Method ¶
func (ev *ExternalConfigChange) Method() EventMethodType
Method is Update.
func (*ExternalConfigChange) String ¶
func (ev *ExternalConfigChange) String() string
String describes ExternalConfigChange event.
func (*ExternalConfigChange) TransactionType ¶
func (ev *ExternalConfigChange) TransactionType() UpdateTransactionType
TransactionType is BestEffort.
func (*ExternalConfigChange) Wait ¶
func (ev *ExternalConfigChange) Wait() error
Wait waits for the result of the ExternalConfigChange event.
type ExternalConfigResync ¶
type ExternalConfigResync struct { Source string ExternalConfig KeyValuePairs // contains filtered or unexported fields }
ExternalConfigResync is a Resync event triggered by external config source. Note: External config from Remote DB uses DBResync instead.
func NewExternalConfigResync ¶
func NewExternalConfigResync(source string, blocking bool) *ExternalConfigResync
NewExternalConfigResync is a constructor for ExternalConfigResync.
func (*ExternalConfigResync) Done ¶
func (ev *ExternalConfigResync) Done(err error)
Done propagates error to the event producer.
func (*ExternalConfigResync) GetName ¶
func (ev *ExternalConfigResync) GetName() string
GetName returns name of the ExternalConfigResync event.
func (*ExternalConfigResync) IsBlocking ¶
func (ev *ExternalConfigResync) IsBlocking() bool
IsBlocking returns what is configured in the constructor.
func (*ExternalConfigResync) Method ¶
func (ev *ExternalConfigResync) Method() EventMethodType
Method is Update.
func (*ExternalConfigResync) String ¶
func (ev *ExternalConfigResync) String() string
String describes ExternalConfigResync event.
func (*ExternalConfigResync) Wait ¶
func (ev *ExternalConfigResync) Wait() error
Wait waits for the result of the ExternalConfigResync event.
type FatalError ¶
type FatalError struct {
// contains filtered or unexported fields
}
FatalError tells Controller to abort the event loop and stop the agent as soon as possible.
func (*FatalError) Error ¶
func (e *FatalError) Error() string
Error delegates the call to the underlying error.
func (*FatalError) GetOriginalError ¶
func (e *FatalError) GetOriginalError() error
GetOriginalError returns the underlying error.
type HealingResync ¶
type HealingResync struct { Type HealingResyncType Error error // non-nil if the resync is of type AfterError }
HealingResync is supposed to "heal" the contiv-vswitch. It is run either after an error occurred or periodically.
func (*HealingResync) GetName ¶
func (ev *HealingResync) GetName() string
GetName returns name of the HealingResync event.
func (*HealingResync) IsBlocking ¶
func (ev *HealingResync) IsBlocking() bool
IsBlocking returns false.
func (*HealingResync) Method ¶
func (ev *HealingResync) Method() EventMethodType
Method is DownstreamResync for periodic healing, otherwise FullResync is used to heal after an error.
func (*HealingResync) String ¶
func (ev *HealingResync) String() string
String describes HealingResync event.
type HealingResyncType ¶
type HealingResyncType int
HealingResyncType is either Periodic or AfterError.
const ( // Periodic healing resync, when enabled in the configuration, is run periodically // to trigger the Downstream resync (sync between vpp-agent and VPP/Linux). Periodic HealingResyncType = iota // AfterError healing resync is triggered after an event processing ended with error. AfterError )
type KeyValuePairs ¶
KeyValuePairs is a set of key-value pairs.
type KubeStateChange ¶
type KubeStateChange struct { Key string Resource string PrevValue proto.Message // nil if newly added NewValue proto.Message // nil if deleted }
KubeStateChange is an Update event that represents change for one key from Kubernetes state data.
func (*KubeStateChange) Direction ¶
func (ev *KubeStateChange) Direction() UpdateDirectionType
Direction is forward.
func (*KubeStateChange) GetName ¶
func (ev *KubeStateChange) GetName() string
GetName returns name of the KubeStateChange event.
func (*KubeStateChange) IsBlocking ¶
func (ev *KubeStateChange) IsBlocking() bool
IsBlocking returns false.
func (*KubeStateChange) Method ¶
func (ev *KubeStateChange) Method() EventMethodType
Method is Update.
func (*KubeStateChange) String ¶
func (ev *KubeStateChange) String() string
String describes KubeStateChange event.
func (*KubeStateChange) TransactionType ¶
func (ev *KubeStateChange) TransactionType() UpdateTransactionType
TransactionType is BestEffort.
type KubeStateData ¶
type KubeStateData map[string]KeyValuePairs // resource name -> {(key, value)}
KubeStateData contains Kubernetes state data organized as key-value pairs sorted by the resource type.
func NewKubeStateData ¶
func NewKubeStateData() KubeStateData
NewKubeStateData is a constructor for KubeStateData.
type ResyncOperations ¶
type ResyncOperations interface { // Put add request to the transaction to add or modify a value. // <value> cannot be nil. Put(key string, value proto.Message) // Get is used to obtain value already prepared to be applied by this transaction. // Until the transaction is committed, provided values can still be changed. // Returns nil if the value is set to be deleted, or has not been set at all. Get(key string) proto.Message }
ResyncOperations lists operations needed to build transaction for Resync-type events.
type Shutdown ¶
type Shutdown struct {
// contains filtered or unexported fields
}
Shutdown event is triggered when the agent is being closed.
func NewShutdownEvent ¶
func NewShutdownEvent() *Shutdown
NewShutdownEvent is constructor for Shutdown event.
func (*Shutdown) Direction ¶
func (ev *Shutdown) Direction() UpdateDirectionType
Direction is forward.
func (*Shutdown) TransactionType ¶
func (ev *Shutdown) TransactionType() UpdateTransactionType
TransactionType is BestEffort.
type Transaction ¶
type Transaction interface { UpdateOperations // Commit applies the requested transaction changes. Commit(ctx context.Context) (seqNum uint64, err error) }
Transaction defines operations needed to build and commit a transaction.
type UpdateDirectionType ¶
type UpdateDirectionType int
UpdateDirectionType is either Forward or Reverse.
const ( // Forward event is processed by handlers in the exact same order as passed // to the Controller - ensuring for every handler that its dependencies // have already reacted to the event. Forward UpdateDirectionType = iota // Reverse event is processed by handlers in the backward order, ensuring // for every handler that its dependencies are still in the pre-event state. Reverse )
type UpdateEvent ¶
type UpdateEvent interface { // TransactionType defines how to treat already executed changes of a failed // event processing - whether to keep them (and be as close to the desired // state as it was possible) or to revert them (a proper transaction). TransactionType() UpdateTransactionType // Direction determines the direction in which the event should flow through // the event handlers. Direction() UpdateDirectionType }
UpdateEvent can be reacted to by an incremental change, as opposed to the full re-synchronization.
type UpdateOperations ¶
type UpdateOperations interface { ResyncOperations // Delete adds request to the transaction to delete an existing value. Delete(key string) }
UpdateOperations lists operations needed to build transaction for Update-type events.
type UpdateTransactionType ¶
type UpdateTransactionType int
UpdateTransactionType is either BestEffort or RevertOnFailure.
const ( // BestEffort transaction continues even if non-fatal, non-abort error // is returned (to get as close to the desired state as it is possible). BestEffort UpdateTransactionType = iota // RevertOnFailure tells the Controller to stop event processing when any error // is returned and to revert already executed changes. RevertOnFailure )