gce

package
v0.0.0-...-5db00e0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2017 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithMetadataConfig

func WithMetadataConfig(conf config.Config, meta *Metadata) (config.Config, error)

WithMetadataConfig loads config from a GCE VM environment, in particular loading metadata from GCE's instance metadata. https://cloud.google.com/compute/docs/storing-retrieving-metadata

Types

type Backend

type Backend struct {
	// contains filtered or unexported fields
}

Backend represents the GCE backend, which provides and interface for both scheduling and scaling.

func NewBackend

func NewBackend(conf config.Config, log *logger.Logger) (*Backend, error)

NewBackend returns a new Google Cloud Engine Backend instance.

func (*Backend) GetOffer

func (s *Backend) GetOffer(j *tes.Task) *scheduler.Offer

GetOffer returns an offer based on available Google Cloud VM node instances.

func (*Backend) ShouldStartNode

func (s *Backend) ShouldStartNode(n *pbs.Node) bool

ShouldStartNode tells the scaler loop which nodes belong to this backend, basically.

func (*Backend) StartNode

func (s *Backend) StartNode(n *pbs.Node) error

StartNode calls out to GCE APIs to start a new node instance.

type Client

type Client interface {
	Templates() []pbs.Node
	StartNode(tplName, serverAddress, nodeID string) error
}

Client is the interface the scheduler/scaler uses to interact with the GCE API. Mainly, the scheduler needs to be able to look up an instance template, or start a node instance.

type Metadata

type Metadata struct {
	Instance struct {
		Name       string
		Hostname   string
		Zone       string
		Attributes struct {
			FunnelConfig            string `json:"funnel-config"`
			FunnelNodeServerAddress string `json:"funnel-node-serveraddress"`
		}
	}
	Project struct {
		ProjectID string `json:"projectId"`
	}
}

Metadata contains a subset of details available from GCE VM metadata.

func LoadMetadata

func LoadMetadata() (*Metadata, error)

LoadMetadata loads metadata from the GCE VM metadata server.

func LoadMetadataFromURL

func LoadMetadataFromURL(url string) (*Metadata, error)

LoadMetadataFromURL loads metadata from the given URL.

type MockBackend

type MockBackend struct {
	*Backend
	InstancesInserted []*compute.Instance
	// contains filtered or unexported fields
}

MockBackend is a GCE backend that doesn't communicate with Google Cloud APIs, which is useful for testing.

func NewMockBackend

func NewMockBackend(conf config.Config, fac scheduler.WorkerFactory) (*MockBackend, error)

NewMockBackend returns a GCE scheduler backend that doesn't communicate with Google Cloud APIs, Useful for testing.

func (*MockBackend) InsertInstance

func (m *MockBackend) InsertInstance(project, zone string, i *compute.Instance) (*compute.Operation, error)

InsertInstance defines a mock implementation of the Wrapper interface which starts an in-memory node routine.

func (*MockBackend) ListInstanceTemplates

func (m *MockBackend) ListInstanceTemplates(proj string) (*compute.InstanceTemplateList, error)

ListInstanceTemplates defines a mock implementation of the Wrapper interface which returns a hard-coded list of instance templates.

func (*MockBackend) ListMachineTypes

func (m *MockBackend) ListMachineTypes(proj, zone string) (*compute.MachineTypeList, error)

ListMachineTypes defines a mock implementation of the Wrapper interface which returns a hard-coded list of machine types.

type Wrapper

type Wrapper interface {
	InsertInstance(project, zone string, instance *compute.Instance) (*compute.Operation, error)
	ListMachineTypes(project, zone string) (*compute.MachineTypeList, error)
	ListInstanceTemplates(project string) (*compute.InstanceTemplateList, error)
}

Wrapper represents a simpler version of the Google Cloud Compute Service interface provided by the google library. The GCE client API is very complex and hard to test against, so this wrapper simplifies things down to only what funnel needs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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