traffic

package
v0.34.2 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 20 Imported by: 11

Documentation

Index

Constants

View Source
const DefaultTarget = ""

DefaultTarget is the unnamed default target for the traffic.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Group of traffic splits.  Un-named targets are grouped together
	// under the key `DefaultTarget`, and named target are under the respective
	// name.  This is used to configure network configuration to
	// realize a route's setting.
	Targets map[string]RevisionTargets

	// Visibility of the traffic targets.
	Visibility map[string]netv1alpha1.IngressVisibility

	// The referred `Configuration`s and `Revision`s.
	Configurations map[string]*v1.Configuration
	Revisions      map[string]*v1.Revision

	// MissingTargets are references to Configurations or Revisions
	// that are missing
	MissingTargets []corev1.ObjectReference
	// contains filtered or unexported fields
}

Config encapsulates details of our traffic so that we don't need to make API calls, or use details of the route beyond its ObjectMeta to make routing changes.

func BuildTrafficConfiguration

func BuildTrafficConfiguration(configLister listers.ConfigurationLister, revLister listers.RevisionLister,
	r *v1.Route) (*Config, error)

BuildTrafficConfiguration consolidates and flattens the Route.Spec.Traffic to the Revision-level. It also provides a complete lists of Configurations and Revisions referred by the Route, directly or indirectly. These referred targets are keyed by name for easy access.

In the case that some target is missing, an error of type TargetError will be returned.

func (*Config) BuildRollout added in v0.19.0

func (cfg *Config) BuildRollout() *Rollout

BuildRollout builds the current rollout state. It is expected to be invoked after applySpecTraffic. Returned Rollout will be sorted by tag and within tag by configuration (only default tag can have more than configuration object attached).

func (*Config) GetRevisionTrafficTargets

func (cfg *Config) GetRevisionTrafficTargets(ctx context.Context, r *v1.Route, ro *Rollout) ([]v1.TrafficTarget, error)

GetRevisionTrafficTargets returns a list of TrafficTarget flattened to the RevisionName, and having ConfigurationName cleared out.

type ConfigurationRollout added in v0.19.0

type ConfigurationRollout struct {
	// Name + tag pair uniquely identifies the rollout target.
	// `tag` will be empty, if this is the `DefaultTarget`.
	ConfigurationName string `json:"configurationName"`
	Tag               string `json:"tag,omitempty"`

	// Percent denotes the total percentage for this configuration.
	// The individual percentages of the Revisions below will sum to this
	// number.
	Percent int `json:"percent"`

	// The revisions in the rollout. In steady state this should
	// contain 0 (no revision is ready) or 1 (rollout done).
	// During the actual rollout it will contain N revisions
	// ordered from oldest to the newest.
	// At the end of the rollout the latest (the tail of the list)
	// will receive 100% of the traffic sent to the key.
	// Note: that it is not 100% of the route traffic, in more complex cases.
	Revisions []RevisionRollout `json:"revisions,omitempty"`

	// StepParams describes rollout params for the configuration.
	StepParams RolloutParams `json:"stepParams"`
}

ConfigurationRollout describes the rollout state for a given config+tag pair.

type RevisionRollout added in v0.19.0

type RevisionRollout struct {
	// Name of the revision.
	RevisionName string `json:"revisionName"`
	// How much traffic is routed to the revision. This is a share
	// of total Route traffic, not the relative share of configuration
	// target percentage.
	Percent int `json:"percent"`
}

RevisionRollout describes the revision in the config rollout.

type RevisionTarget

type RevisionTarget struct {
	v1.TrafficTarget
	Protocol net.ProtocolType
}

A RevisionTarget adds the transport protocol and the service name of a Revision to a flattened TrafficTarget.

type RevisionTargets

type RevisionTargets []RevisionTarget

RevisionTargets is a collection of revision targets.

type Rollout added in v0.19.0

type Rollout struct {
	// Configurations are sorted by tag first and within same tag, by configuration name.
	Configurations []*ConfigurationRollout `json:"configurations,omitempty"`
}

Rollout encapsulates the current rollout state of the system. Since the route might reference more than one configuration.

There may be several rollouts going on at the same time for the same configuration if there is a tag configured traffic target.

func (*Rollout) Done added in v0.20.0

func (cur *Rollout) Done() bool

Done returns true if all the Configuration rollouts in this Rollout have completed.

func (*Rollout) ObserveReady added in v0.20.0

func (cur *Rollout) ObserveReady(ctx context.Context, nowTS int64, durationSecs float64)

ObserveReady traverses the configs and the ones that are in rollout but have not observed step time yet, will have it set, to max(1, nowTS-cfg.StartTime).

func (*Rollout) RolloutsByTag added in v0.20.0

func (cur *Rollout) RolloutsByTag(t string) []*ConfigurationRollout

RolloutsByTag returns the ConfigurationRollout(s) for the given tag.

func (*Rollout) Step added in v0.19.0

func (cur *Rollout) Step(ctx context.Context, prev *Rollout, nowTS int64) (*Rollout, int64)

Step merges this rollout object with the previous state and returns a new Rollout object representing the merged state. At the end of the call the returned object will contain the desired traffic shape. Step will return cur if no previous state was available. Second return value is the Unix timestamp in ns of the closest rollout action to take or 0, if no rollout is currently scheduled.

func (*Rollout) Validate added in v0.20.0

func (cur *Rollout) Validate() bool

Validate validates current rollout for inconsistencies. This is expected to be invoked after annotation deserialization. If it returns false — the deserialized object should be discarded.

type RolloutParams added in v0.20.0

type RolloutParams struct {
	// StartTime is the Unix timestamp in ns by when (+/- reconcile precision)
	// the Rollout has started.
	// This is required to compute step time and deadline.
	StartTime int64 `json:"starttime,omitempty"`

	// NextStepTime is the Unix timestamp in ns when the next
	// rollout step should performed.
	NextStepTime int64 `json:"nextStepTime,omitempty"`

	// StepDuration is the number of nanoseconds between two successive steps
	// of rollout.
	StepDuration int64 `json:"stepDuration,omitempty"`

	// How much traffic to move in a single step.
	StepSize int `json:"stepSize,omitempty"`
}

RolloutParams contains the timing and sizing parameters for the ConfigurationRollout.

type TargetError

type TargetError interface {
	error

	// MarkBadTrafficTarget marks a RouteStatus with Condition corresponding
	// to the error case of the traffic target.
	MarkBadTrafficTarget(rs *v1.RouteStatus)

	// IsFailure returns whether a TargetError is a true failure, e.g.
	// a Configuration fails to become ready.
	IsFailure() bool
}

TargetError gives details about an invalid traffic target.

Jump to

Keyboard shortcuts

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