platform

package
Version: v0.3.0-prep Latest Latest
Warning

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

Go to latest
Published: May 4, 2017 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package platform will hold abstractions and data types common to supported platforms. We don't know what all of those will look like, yet. So the package is mostly empty.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptySelector        = errors.New("empty selector")
	ErrWrongResourceKind    = errors.New("new definition does not match existing resource")
	ErrNoMatchingService    = errors.New("no matching service")
	ErrServiceHasNoSelector = errors.New("service has no selector")
	ErrNoMatching           = errors.New("no matching replication controllers or deployments")
	ErrMultipleMatching     = errors.New("multiple matching replication controllers or deployments")
	ErrNoMatchingImages     = errors.New("no matching images")
)

These errors all represent logical problems with platform configuration, and may be recoverable; e.g., it might be fine if a service does not have a matching RC/deployment.

View Source
var (
	BusMetricsImpl = BusMetrics{
		KickCount: prometheus.NewCounterFrom(stdprometheus.CounterOpts{
			Namespace: "flux",
			Subsystem: "bus",
			Name:      "kick_total",
			Help:      "Count of bus subscriptions kicked off by a newer subscription.",
		}, []string{}),
	}
)

Functions

func ClusterError

func ClusterError(err error) error

func PlatformTestBattery

func PlatformTestBattery(t *testing.T, wrap func(mock Platform) Platform)

func UnavailableError

func UnavailableError(err error) error

func UpgradeNeededError

func UpgradeNeededError(err error) error

Types

type ApplyError

type ApplyError map[flux.ServiceID]error

func (ApplyError) Error

func (e ApplyError) Error() string

type BusMetrics

type BusMetrics struct {
	KickCount metrics.Counter
}

BusMetrics has metrics for messages buses.

func (BusMetrics) IncrKicks

func (m BusMetrics) IncrKicks(inst flux.InstanceID)

type Connecter

type Connecter interface {
	// Connect returns a platform for the instance specified. An error
	// is returned only if there is a problem (possibly transient)
	// with the underlying mechanism (i.e., not if the platform is
	// simply not known to be connected at this time).
	Connect(inst flux.InstanceID) (Platform, error)
}

For getting a connection to a platform; this can happen in different ways, e.g., by having direct access to Kubernetes in standalone mode, or by going via a message bus.

type Container

type Container struct {
	Name  string
	Image string
}

A Container represents a container specification in a pod. The Name identifies it within the pod, and the Image says which image it's configured to run.

type ContainersOrExcuse

type ContainersOrExcuse struct {
	Excuse     string
	Containers []Container
}

Sometimes we care if we can't find the containers for a service, sometimes we just want the information we can get.

type FatalError

type FatalError struct {
	Err error
}

Wrap errors in this to indicate that the platform should be considered dead, and disconnected.

func (FatalError) Error

func (err FatalError) Error() string

type MessageBus

type MessageBus interface {
	Connecter
	// Subscribe registers a platform as the daemon for the instance
	// specified.
	Subscribe(inst flux.InstanceID, p Platform, done chan<- error)
	// Ping returns nil if the daemon for the instance given is known
	// to be connected, or ErrPlatformNotAvailable otherwise. NB this
	// differs from the semantics of `Connecter.Connect`.
	Ping(inst flux.InstanceID) error
}

MessageBus handles routing messages to/from the matching platform.

type MockPlatform

type MockPlatform struct {
	AllServicesArgTest func(string, flux.ServiceIDSet) error
	AllServicesAnswer  []Service
	AllServicesError   error

	SomeServicesArgTest func([]flux.ServiceID) error
	SomeServicesAnswer  []Service
	SomeServicesError   error

	ApplyArgTest func([]ServiceDefinition) error
	ApplyError   error

	PingError error

	VersionAnswer string
	VersionError  error

	ExportAnswer []byte
	ExportError  error

	SyncArgTest func(SyncDef) error
	SyncError   error
}

func (*MockPlatform) AllServices

func (p *MockPlatform) AllServices(ns string, ss flux.ServiceIDSet) ([]Service, error)

func (*MockPlatform) Apply

func (p *MockPlatform) Apply(defs []ServiceDefinition) error

func (*MockPlatform) Export

func (p *MockPlatform) Export() ([]byte, error)

func (*MockPlatform) Ping

func (p *MockPlatform) Ping() error

func (*MockPlatform) SomeServices

func (p *MockPlatform) SomeServices(ss []flux.ServiceID) ([]Service, error)

func (*MockPlatform) Sync

func (p *MockPlatform) Sync(def SyncDef) error

func (*MockPlatform) Version

func (p *MockPlatform) Version() (string, error)

type Platform

type Platform interface {
	PlatformV5
}

Platform is the interface various platforms fulfill, e.g. *kubernetes.Cluster

func Instrument

func Instrument(p Platform) Platform

type PlatformV4

type PlatformV4 interface {
	AllServices(maybeNamespace string, ignored flux.ServiceIDSet) ([]Service, error)
	SomeServices([]flux.ServiceID) ([]Service, error)
	Apply([]ServiceDefinition) error
	Ping() error
	Version() (string, error)
}

type PlatformV5

type PlatformV5 interface {
	PlatformV4
	// Additional methods accumulate here as we develop V5
	Export() ([]byte, error)
	Sync(SyncDef) error
}

type ResourceDef

type ResourceDef []byte

Yep, resources are defined by opaque bytes. It's up to the platform at the other end to do the right thing.

type Service

type Service struct {
	ID       flux.ServiceID
	IP       string
	Metadata map[string]string // a grab bag of goodies, likely platform-specific
	Status   string            // A status summary for display

	Containers ContainersOrExcuse
}

Service describes a platform service, generally a floating IP with one or more exposed ports that map to a load-balanced pool of instances. Eventually this type will generalize to something of a lowest-common-denominator for all supported platforms, but right now it looks a lot like a Kubernetes service.

func (Service) ContainersOrError

func (s Service) ContainersOrError() ([]Container, error)

func (Service) ContainersOrNil

func (s Service) ContainersOrNil() []Container

type ServiceDefinition

type ServiceDefinition struct {
	ServiceID     flux.ServiceID
	NewDefinition []byte // of the pod controller e.g. deployment
	Async         bool   // Should this definition be applied without waiting for the result.
}

ServiceDefinition is provided to platform.Apply method/s.

type StandaloneMessageBus

type StandaloneMessageBus struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewStandaloneMessageBus

func NewStandaloneMessageBus(metrics BusMetrics) *StandaloneMessageBus

func (*StandaloneMessageBus) Connect

func (s *StandaloneMessageBus) Connect(inst flux.InstanceID) (Platform, error)

Connect hands back a platform, given an instance ID. Since the platform will not always be connected, and we want to be able to process operations that don't involve a platform (like setting config), we have a special value for a disconnected platform, rather than returning an error.

func (*StandaloneMessageBus) Ping

func (s *StandaloneMessageBus) Ping(inst flux.InstanceID) error

Ping returns nil if the specified instance is connected, and an error if not.

func (*StandaloneMessageBus) Subscribe

func (s *StandaloneMessageBus) Subscribe(inst flux.InstanceID, p Platform, complete chan<- error)

Subscribe introduces a Platform to the message bus, so that requests can be routed to it. Once the connection is closed -- trying to use it is the only way to tell if it's closed -- the error representing the cause will be sent to the channel supplied.

func (*StandaloneMessageBus) Version

func (s *StandaloneMessageBus) Version(inst flux.InstanceID) (string, error)

Version returns the fluxd version for the connected instance if the specified instance is connected, and an error if not.

type SyncAction

type SyncAction struct {
	// The ID is just a handle for labeling any error. No other
	// meaning is attached to it.
	ResourceID string
	Delete     ResourceDef
	Apply      ResourceDef
}

The action(s) to take on a particular resource. This should just be done in order, i.e.,:

1. delete if something in Delete
2. apply if something in Apply

type SyncDef

type SyncDef struct {
	// The actions to undertake
	Actions []SyncAction
}

type SyncError

type SyncError map[string]error

func (SyncError) Error

func (err SyncError) Error() string

Directories

Path Synopsis
Package kubernetes provides abstractions for the Kubernetes platform.
Package kubernetes provides abstractions for the Kubernetes platform.
rpc

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL