cluster

package
v0.16.8 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const HostnameSeparator = '.'

Variables

View Source
var (
	// Errors types returned by the Exec function on the client interface
	ErrExec                        = errors.New("remote command execute error")
	ErrExecNoServiceWithName       = fmt.Errorf("%w: no such service exists with that name", ErrExec)
	ErrExecServiceNotRunning       = fmt.Errorf("%w: service with that name is not running", ErrExec)
	ErrExecCommandExecutionFailed  = fmt.Errorf("%w: command execution failed", ErrExec)
	ErrExecCommandDoesNotExist     = fmt.Errorf("%w: command could not be executed because it does not exist", ErrExec)
	ErrExecDeploymentNotYetRunning = fmt.Errorf("%w: deployment is not yet active", ErrExec)
	ErrExecPodIndexOutOfRange      = fmt.Errorf("%w: pod index out of range", ErrExec)
	ErrUnknownStorageClass         = errors.New("inventory: unknown storage class")
)
View Source
var ErrHostnameNotAllowed = errors.New("hostname not allowed")
View Source
var (
	ErrLeaseInactive = errors.New("Inactive Lease")
)
View Source
var ErrNotRunning = errors.New("not running")

ErrNotRunning is the error when service is not running

Functions

func ErrorIsOkToSendToClient added in v0.12.2

func ErrorIsOkToSendToClient(err error) bool

func NewServiceLog added in v0.2.2

func NewServiceLog(name string, stream io.ReadCloser) *ctypes.ServiceLog

NewServiceLog creates and returns a service log with provided details

func NewSimpleHostnames added in v0.14.0

func NewSimpleHostnames() clustertypes.HostnameServiceClient

Types

type Client added in v0.0.8

type Client interface {
	ReadClient
	Deploy(ctx context.Context, lID mtypes.LeaseID, mgroup *manifest.Group) error
	TeardownLease(context.Context, mtypes.LeaseID) error
	Deployments(context.Context) ([]ctypes.Deployment, error)
	Inventory(context.Context) (ctypes.Inventory, error)
	Exec(ctx context.Context,
		lID mtypes.LeaseID,
		service string,
		podIndex uint,
		cmd []string,
		stdin io.Reader,
		stdout io.Writer,
		stderr io.Writer,
		tty bool,
		tsq remotecommand.TerminalSizeQueue) (ctypes.ExecResult, error)

	// Connect a given hostname to a deployment
	ConnectHostnameToDeployment(ctx context.Context, directive ctypes.ConnectHostnameToDeploymentDirective) error
	// Remove a given hostname from a deployment
	RemoveHostnameFromDeployment(ctx context.Context, hostname string, leaseID mtypes.LeaseID, allowMissing bool) error

	// Declare that a given deployment should be connected to a given hostname
	DeclareHostname(ctx context.Context, lID mtypes.LeaseID, host string, serviceName string, externalPort uint32) error
	// Purge any hostnames associated with a given deployment
	PurgeDeclaredHostnames(ctx context.Context, lID mtypes.LeaseID) error

	PurgeDeclaredHostname(ctx context.Context, lID mtypes.LeaseID, hostname string) error

	// KubeVersion returns the version information of kubernetes running in the cluster
	KubeVersion() (*version.Info, error)
}

Client interface lease and deployment methods

func NullClient added in v0.0.8

func NullClient() Client

NullClient returns nullClient instance

type Cluster

type Cluster interface {
	Reserve(mtypes.OrderID, atypes.ResourceGroup) (ctypes.Reservation, error)
	Unreserve(mtypes.OrderID) error
}

Cluster is the interface that wraps Reserve and Unreserve methods

type Config added in v0.9.1

type Config struct {
	InventoryResourcePollPeriod     time.Duration
	InventoryResourceDebugFrequency uint
	InventoryExternalPortQuantity   uint
	CPUCommitLevel                  float64
	MemoryCommitLevel               float64
	StorageCommitLevel              float64
	BlockedHostnames                []string
	DeploymentIngressStaticHosts    bool
	DeploymentIngressDomain         string
	ClusterSettings                 map[interface{}]interface{}
}

func NewDefaultConfig added in v0.9.1

func NewDefaultConfig() Config

type ReadClient added in v0.7.3

type ReadClient interface {
	LeaseStatus(context.Context, mtypes.LeaseID) (*ctypes.LeaseStatus, error)
	LeaseEvents(context.Context, mtypes.LeaseID, string, bool) (ctypes.EventsWatcher, error)
	LeaseLogs(context.Context, mtypes.LeaseID, string, bool, *int64) ([]*ctypes.ServiceLog, error)
	ServiceStatus(context.Context, mtypes.LeaseID, string) (*ctypes.ServiceStatus, error)

	AllHostnames(context.Context) ([]ctypes.ActiveHostname, error)
	GetManifestGroup(context.Context, mtypes.LeaseID) (bool, crd.ManifestGroup, error)

	ObserveHostnameState(ctx context.Context) (<-chan ctypes.HostnameResourceEvent, error)
	GetHostnameDeploymentConnections(ctx context.Context) ([]ctypes.LeaseIDHostnameConnection, error)
}

type ReservationResult added in v0.14.0

type ReservationResult struct {
	ChErr               <-chan error
	ChWithheldHostnames <-chan []string
}

func (ReservationResult) Wait added in v0.14.0

func (rr ReservationResult) Wait(wait <-chan struct{}) ([]string, error)

type Service

type Service interface {
	StatusClient
	Cluster
	Close() error
	Ready() <-chan struct{}
	Done() <-chan struct{}
	HostnameService() ctypes.HostnameServiceClient
	TransferHostname(ctx context.Context, leaseID mtypes.LeaseID, hostname string, serviceName string, externalPort uint32) error
}

Service manage compute cluster for the provider. Will eventually integrate with kubernetes, etc...

func NewService

func NewService(ctx context.Context, session session.Session, bus pubsub.Bus, client Client, cfg Config) (Service, error)

NewService returns new Service instance

type SimpleHostnames added in v0.9.3

type SimpleHostnames struct {
	Hostnames map[string]hostnameID
	// contains filtered or unexported fields

} /* Used in test code */

func (*SimpleHostnames) CanReserveHostnames added in v0.9.3

func (sh *SimpleHostnames) CanReserveHostnames(hostnames []string, ownerAddr sdktypes.Address) error

func (*SimpleHostnames) PrepareHostnamesForTransfer added in v0.14.0

func (sh *SimpleHostnames) PrepareHostnamesForTransfer(ctx context.Context, hostnames []string, leaseID mtypes.LeaseID) error

func (*SimpleHostnames) ReleaseHostnames added in v0.9.3

func (sh *SimpleHostnames) ReleaseHostnames(leaseID mtypes.LeaseID) error

func (*SimpleHostnames) ReserveHostnames added in v0.9.3

func (sh *SimpleHostnames) ReserveHostnames(ctx context.Context, hostnames []string, leaseID mtypes.LeaseID) ([]string, error)

type StatusClient added in v0.3.4

type StatusClient interface {
	Status(context.Context) (*ctypes.Status, error)
	FindActiveLease(ctx context.Context, owner sdktypes.Address, dseq uint64, gseq uint32) (bool, mtypes.LeaseID, crd.ManifestGroup, error)
}

StatusClient is the interface which includes status of service

Directories

Path Synopsis
types

Jump to

Keyboard shortcuts

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