updateprocessors

package
v3.8.0-0.dev+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllowAnnotations    = true
	DisallowAnnotations = false
)

Variables

This section is empty.

Functions

func ConvertV2ToV1IPNAT

func ConvertV2ToV1IPNAT(ipnat apiv3.IPNAT) *model.IPNAT

func NewBGPConfigUpdateProcessor

func NewBGPConfigUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync BGPConfiguration data in v1 format for consumption by the BGP daemon.

func NewBGPNodeUpdateProcessor

func NewBGPNodeUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync Node data in v1 format for consumption by the BGP daemon.

func NewClusterInfoUpdateProcessor

func NewClusterInfoUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new NewClusterInfoUpdateProcessor.

func NewConfigUpdateProcessor

func NewConfigUpdateProcessor(
	specType reflect.Type,
	allowAnnotations bool,
	nodeConfigKeyFn NodeConfigKeyFn,
	globalConfigKeyFn GlobalConfigKeyFn,
	valueConverters map[string]ConfigFieldValueToV1ModelValue,
) watchersyncer.SyncerUpdateProcessor

NewConfigUpdateProcessor creates a SyncerUpdateProcessor that can be used to map Configuration-type resources to the v1 model. This converter basically expands each field as a separate key and uses a stringified of the field as the configuration value. If the field is not specified in the configuration resource we expand that that a delete for the associated key.

If the field specifies a "confignamev1" tag, then the value in that tag is used as the config name, otherwise the struct field name is used.

A set of ValueToStringFn can be specified for each of the (converted) field names to handle marshaling the field value into the string value required in the v1 model.

It is assumed that the name of the resource follows the format: - `default` for global - `node.<nodename>` for per-node

If allowAnnotations is set to true, then this helper will also check the annotations for additional config key/values. An annotation prefixed with "config.projectcalico.org/" will be used (prefix removed) as the config key, and the value of the annotation used as the value. These values are not validated, and take precedence over keys of the same name in the Spec - thus it's possible to use an annotation to work around any validation provided on the Spec.

func NewConflictResolvingCacheUpdateProcessor

func NewConflictResolvingCacheUpdateProcessor(v3Kind string, converter ConvertV2ToV1) watchersyncer.SyncerUpdateProcessor

ConflictResolvingNameCacheProcessor implements a cached update processor that may be used to handle resources where the indexing has changed between the v3 and v1 models. In v3 all resources have a single name field which in some cases may be unlinked to the v1 indexes. This means it's potentially possible to have multiple v3 resources that share a common set of indexes when converted to the v1 model - e.g. IPPools in v3 are indexed by arbitrary name, and in v1 by the Pool CIDR, it would be possible to have multiple pools configured with the same CIDR.

This cache may also be used when name conflicts are not an issue, but there is no direct map between the v1 key and the v3 key, for example HostEndpoints have an additional "node" index in the v1 key, so this cache can be used to resolve between the v3 name and the last set of v1 indices to provide the relevant updates.

Notes:

  • this update processor only handles simple 1:1 conversions (i.e. a single v3 model mapping to a single v1 model).
  • generally, validation processing would prevent the user from making configuration changes with conflicting (duplicate) information - but since that operation is not atomic, we need to handle gracefully these situations whether or not that validation processing is in place.
  • since the relationship between the v1 and v3 indexes is not locked, the v1 index for a given v3 resource may be changed by an update.

This cache handles conflicting entries by only syncing the v1 data for the v3 resource with the lowest alphanumeric name. This means:

  • Adding a conflicting resource with a higher alphanumeric name will not result in any syncer update.
  • Deleting the conflicting resource with the lowest alphanumeric name will result in an update using the configuration of the conflicting resource with the next lowest alphanumeric name.
  • Modifying an existing resource (that is already in our cache) is more complicated. It is possible that the modification may alter the v1 key - and in which case we need to effectively treat as a delete (for the old v1 key) and an add for the new v1 key.

func NewFelixConfigUpdateProcessor

func NewFelixConfigUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync FelixConfiguration data in v1 format for consumption by Felix.

func NewFelixNodeUpdateProcessor

func NewFelixNodeUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync Node data in v1 format for consumption by Felix.

func NewGlobalNetworkPolicyUpdateProcessor

func NewGlobalNetworkPolicyUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync GlobalNetworkPolicy data in v1 format for consumption by Felix.

func NewGlobalNetworkSetUpdateProcessor

func NewGlobalNetworkSetUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync GlobalNetworkSet data in v1 format for consumption by Felix.

func NewHostEndpointUpdateProcessor

func NewHostEndpointUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync HostEndpoint data in v1 format for consumption by both Felix and the BGP daemon.

func NewIPPoolUpdateProcessor

func NewIPPoolUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync IPPool data in v1 format for consumption by both Felix and the BGP daemon.

func NewNetworkPolicyUpdateProcessor

func NewNetworkPolicyUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync NetworkPolicy data in v1 format for consumption by Felix.

func NewNetworkSetUpdateProcessor

func NewNetworkSetUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync NetworkSet data in v1 format for consumption by Felix.

func NewProfileUpdateProcessor

func NewProfileUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync Profile data in v1 format for consumption by Felix.

func NewSimpleUpdateProcessor

func NewSimpleUpdateProcessor(v3Kind string, kConverter ConvertV2ToV1Key, vConverter ConvertV2ToV1Value) watchersyncer.SyncerUpdateProcessor

func NewWorkloadEndpointUpdateProcessor

func NewWorkloadEndpointUpdateProcessor() watchersyncer.SyncerUpdateProcessor

Create a new SyncerUpdateProcessor to sync WorkloadEndpoint data in v1 format for consumption by Felix.

func RuleAPIV2ToBackend

func RuleAPIV2ToBackend(ar apiv3.Rule, ns string) model.Rule

RuleAPIToBackend converts an API Rule structure to a Backend Rule structure.

func RulesAPIV2ToBackend

func RulesAPIV2ToBackend(ars []apiv3.Rule, ns string) []model.Rule

Types

type ConfigFieldValueToV1ModelValue

type ConfigFieldValueToV1ModelValue func(value interface{}) interface{}

Convert an arbitrary value to the value used in the v1 model.

type ConvertV2ToV1

type ConvertV2ToV1 func(kvp *model.KVPair) (*model.KVPair, error)

type ConvertV2ToV1Key

type ConvertV2ToV1Key func(v3Key model.ResourceKey) (model.Key, error)

Function signature to convert a v3 model.ResourceKey to a v1 model.Key type

type ConvertV2ToV1Value

type ConvertV2ToV1Value func(interface{}) (interface{}, error)

Function to convert a v3 resource to the v1 value. The converter may filter out results by returning nil. The generic watchersyncer will handle filtered out events by either sending no event or sending delete events depending on whether the entry is currently in the cache.

type FelixNodeUpdateProcessor

type FelixNodeUpdateProcessor struct {
}

FelixNodeUpdateProcessor implements the SyncerUpdateProcessor interface. This converts the v3 node configuration into the v1 data types consumed by confd.

func (*FelixNodeUpdateProcessor) OnSyncerStarting

func (c *FelixNodeUpdateProcessor) OnSyncerStarting()

Sync is restarting - nothing to do for this processor.

func (*FelixNodeUpdateProcessor) Process

func (c *FelixNodeUpdateProcessor) Process(kvp *model.KVPair) ([]*model.KVPair, error)

type GlobalConfigKeyFn

type GlobalConfigKeyFn func(name string) model.Key

Convert the config name to the corresponding global config key

type NodeConfigKeyFn

type NodeConfigKeyFn func(node, name string) model.Key

Convert the node and config name to the corresponding per-node config key

Jump to

Keyboard shortcuts

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