executor

package module
v0.0.0-...-1ada680 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

README

Executor

Note: This repository should be imported as github.com/cceasy/executor.

Let me run that for you

####Learn more about Diego and its components at diego-design-notes

Documentation

Index

Constants

View Source
const (
	HealthcheckTag      = "executor-healthcheck"
	HealthcheckTagValue = "executor-healthcheck"
)

Variables

View Source
var (
	ErrContainerGuidNotAvailable      = registerError("ContainerGuidNotAvailable", "container guid not available", http.StatusBadRequest)
	ErrContainerNotCompleted          = registerError("ContainerNotCompleted", "container must be stopped before it can be deleted", http.StatusBadRequest)
	ErrInsufficientResourcesAvailable = registerError("InsufficientResourcesAvailable", "insufficient resources available", http.StatusServiceUnavailable)
	ErrContainerNotFound              = registerError("ContainerNotFound", "container not found", http.StatusNotFound)
	ErrStepsInvalid                   = registerError("StepsInvalid", "steps invalid", http.StatusBadRequest)
	ErrLimitsInvalid                  = registerError("LimitsInvalid", "container limits invalid", http.StatusBadRequest)
	ErrGuidNotSpecified               = registerError("GuidNotSpecified", "container guid not specified", http.StatusBadRequest)
	ErrInvalidTransition              = registerError("InvalidStateTransition", "container cannot transition to given state", http.StatusConflict)
	ErrFailureToCheckSpace            = registerError("ErrFailureToCheckSpace", "failed to check available space", http.StatusInternalServerError)
	ErrInvalidSecurityGroup           = registerError("ErrInvalidSecurityGroup", "security group has invalid values", http.StatusBadRequest)
	ErrNoProcessToStop                = registerError("ErrNoProcessToStop", "failed to find a process to stop", http.StatusNotFound)
)
View Source
var ErrUnknownEventType = errors.New("unknown event type")
View Source
var Errors = map[string]Error{}

Functions

func EnvironmentVariablesToModel

func EnvironmentVariablesToModel(envVars []EnvironmentVariable) []models.EnvironmentVariable

Types

type AllocationFailure

type AllocationFailure struct {
	AllocationRequest
	ErrorMsg string
}

func NewAllocationFailure

func NewAllocationFailure(req *AllocationRequest, msg string) AllocationFailure

func (*AllocationFailure) Error

func (fail *AllocationFailure) Error() string

type AllocationRequest

type AllocationRequest struct {
	Guid string
	Resource
	Tags
}

func NewAllocationRequest

func NewAllocationRequest(guid string, resource *Resource, tags Tags) AllocationRequest

func (*AllocationRequest) Validate

func (a *AllocationRequest) Validate() error

type BindMountMode

type BindMountMode uint8
const (
	BindMountModeRO BindMountMode = 0
	BindMountModeRW BindMountMode = 1
)

type CachedDependency

type CachedDependency struct {
	Name              string `json:"name"`
	From              string `json:"from"`
	To                string `json:"to"`
	CacheKey          string `json:"cache_key"`
	LogSource         string `json:"log_source"`
	ChecksumValue     string `json:"checksum_value"`
	ChecksumAlgorithm string `json:"checksum_algorithm"`
}

type CertificateProperties

type CertificateProperties struct {
	OrganizationalUnit []string `json:"organizational_unit"`
}

type Client

type Client interface {
	Ping(logger lager.Logger) error
	AllocateContainers(logger lager.Logger, requests []AllocationRequest) ([]AllocationFailure, error)
	GetContainer(logger lager.Logger, guid string) (Container, error)
	RunContainer(lager.Logger, *RunRequest) error
	StopContainer(logger lager.Logger, guid string) error
	DeleteContainer(logger lager.Logger, guid string) error
	ListContainers(lager.Logger) ([]Container, error)
	GetBulkMetrics(lager.Logger) (map[string]Metrics, error)
	RemainingResources(lager.Logger) (ExecutorResources, error)
	TotalResources(lager.Logger) (ExecutorResources, error)
	GetFiles(logger lager.Logger, guid string, path string) (io.ReadCloser, error)
	VolumeDrivers(logger lager.Logger) ([]string, error)
	SubscribeToEvents(lager.Logger) (EventSource, error)
	Healthy(lager.Logger) bool
	SetHealthy(lager.Logger, bool)
	Cleanup(lager.Logger)
}

type Container

type Container struct {
	Guid string `json:"guid"`
	Resource
	RunInfo
	Tags        Tags
	State       State              `json:"state"`
	AllocatedAt int64              `json:"allocated_at"`
	ExternalIP  string             `json:"external_ip"`
	InternalIP  string             `json:"internal_ip"`
	RunResult   ContainerRunResult `json:"run_result"`
	MemoryLimit uint64             `json:"memory_limit"`
	DiskLimit   uint64             `json:"disk_limit"`
}

func NewContainerFromResource

func NewContainerFromResource(guid string, resource *Resource, tags Tags) Container

func NewReservedContainerFromAllocationRequest

func NewReservedContainerFromAllocationRequest(req *AllocationRequest, allocatedAt int64) Container

func (Container) Copy

func (newContainer Container) Copy() Container

func (*Container) HasTags

func (c *Container) HasTags(tags Tags) bool

func (*Container) IsCreated

func (c *Container) IsCreated() bool

func (*Container) TransistionToCreate

func (c *Container) TransistionToCreate() error

func (*Container) TransistionToInitialize

func (c *Container) TransistionToInitialize(req *RunRequest) error

func (*Container) TransitionToComplete

func (c *Container) TransitionToComplete(failed bool, failureReason string)

func (*Container) ValidateTransitionTo

func (c *Container) ValidateTransitionTo(newState State) bool

type ContainerCompleteEvent

type ContainerCompleteEvent struct {
	RawContainer Container `json:"container"`
}

func NewContainerCompleteEvent

func NewContainerCompleteEvent(container Container) ContainerCompleteEvent

func (ContainerCompleteEvent) Container

func (e ContainerCompleteEvent) Container() Container

func (ContainerCompleteEvent) EventType

func (ContainerCompleteEvent) EventType() EventType

type ContainerMetrics

type ContainerMetrics struct {
	MemoryUsageInBytes uint64        `json:"memory_usage_in_bytes"`
	DiskUsageInBytes   uint64        `json:"disk_usage_in_bytes"`
	MemoryLimitInBytes uint64        `json:"memory_limit_in_bytes"`
	DiskLimitInBytes   uint64        `json:"disk_limit_in_bytes"`
	TimeSpentInCPU     time.Duration `json:"time_spent_in_cpu"`
}

type ContainerReservedEvent

type ContainerReservedEvent struct {
	RawContainer Container `json:"container"`
}

func NewContainerReservedEvent

func NewContainerReservedEvent(container Container) ContainerReservedEvent

func (ContainerReservedEvent) Container

func (e ContainerReservedEvent) Container() Container

func (ContainerReservedEvent) EventType

func (ContainerReservedEvent) EventType() EventType

type ContainerRunResult

type ContainerRunResult struct {
	Failed        bool   `json:"failed"`
	FailureReason string `json:"failure_reason"`

	Stopped bool `json:"stopped"`
}

type ContainerRunningEvent

type ContainerRunningEvent struct {
	RawContainer Container `json:"container"`
}

func NewContainerRunningEvent

func NewContainerRunningEvent(container Container) ContainerRunningEvent

func (ContainerRunningEvent) Container

func (e ContainerRunningEvent) Container() Container

func (ContainerRunningEvent) EventType

func (ContainerRunningEvent) EventType() EventType

type DiskLimitScope

type DiskLimitScope uint8
const (
	ExclusiveDiskLimit DiskLimitScope = iota
	TotalDiskLimit     DiskLimitScope = iota
)

type EnvironmentVariable

type EnvironmentVariable struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

func EnvironmentVariablesFromModel

func EnvironmentVariablesFromModel(envVars []*models.EnvironmentVariable) []EnvironmentVariable

type Error

type Error interface {
	error

	Name() string
	HttpCode() int
}

type Event

type Event interface {
	EventType() EventType
}

type EventSource

type EventSource interface {
	Next() (Event, error)
	Close() error
}

type EventType

type EventType string
const (
	EventTypeInvalid EventType = ""

	EventTypeContainerComplete EventType = "container_complete"
	EventTypeContainerRunning  EventType = "container_running"
	EventTypeContainerReserved EventType = "container_reserved"
)

type ExecutorResources

type ExecutorResources struct {
	MemoryMB   int `json:"memory_mb"`
	DiskMB     int `json:"disk_mb"`
	Containers int `json:"containers"`
}

func NewExecutorResources

func NewExecutorResources(memoryMB, diskMB, containers int) ExecutorResources

func (*ExecutorResources) Add

func (r *ExecutorResources) Add(res *Resource)

func (ExecutorResources) Copy

func (*ExecutorResources) Subtract

func (r *ExecutorResources) Subtract(res *Resource) bool

type InnerContainer

type InnerContainer Container

type LifecycleEvent

type LifecycleEvent interface {
	Container() Container
	// contains filtered or unexported methods
}

type LogConfig

type LogConfig struct {
	Guid       string `json:"guid"`
	Index      int    `json:"index"`
	SourceName string `json:"source_name"`
}

type Metrics

type Metrics struct {
	MetricsConfig
	ContainerMetrics
}

type MetricsConfig

type MetricsConfig struct {
	Guid  string `json:"guid"`
	Index int    `json:"index"`
}

type Network

type Network struct {
	Properties map[string]string `json:"properties,omitempty"`
}

type PortMapping

type PortMapping struct {
	ContainerPort uint16 `json:"container_port"`
	HostPort      uint16 `json:"host_port,omitempty"`
}

type Resource

type Resource struct {
	MemoryMB   int    `json:"memory_mb"`
	DiskMB     int    `json:"disk_mb"`
	MaxPids    int    `json:"max_pids"`
	RootFSPath string `json:"rootfs"`
}

func NewResource

func NewResource(memoryMB, diskMB, maxPids int, rootFSPath string) Resource

type RunInfo

type RunInfo struct {
	CPUWeight                     uint                        `json:"cpu_weight"`
	DiskScope                     DiskLimitScope              `json:"disk_scope,omitempty"`
	Ports                         []PortMapping               `json:"ports"`
	LogConfig                     LogConfig                   `json:"log_config"`
	MetricsConfig                 MetricsConfig               `json:"metrics_config"`
	StartTimeoutMs                uint                        `json:"start_timeout_ms"`
	Privileged                    bool                        `json:"privileged"`
	CachedDependencies            []CachedDependency          `json:"cached_dependencies"`
	Setup                         *models.Action              `json:"setup"`
	Action                        *models.Action              `json:"run"`
	Monitor                       *models.Action              `json:"monitor"`
	CheckDefinition               *models.CheckDefinition     `json:"check_definition"`
	EgressRules                   []*models.SecurityGroupRule `json:"egress_rules,omitempty"`
	Env                           []EnvironmentVariable       `json:"env,omitempty"`
	TrustedSystemCertificatesPath string                      `json:"trusted_system_certificates_path,omitempty"`
	VolumeMounts                  []VolumeMount               `json:"volume_mounts"`
	Network                       *Network                    `json:"network,omitempty"`
	CertificateProperties         CertificateProperties       `json:"certificate_properties"`
	ImageUsername                 string                      `json:"image_username"`
	ImagePassword                 string                      `json:"image_password"`
}

type RunRequest

type RunRequest struct {
	Guid string
	RunInfo
	Tags
}

func NewRunRequest

func NewRunRequest(guid string, runInfo *RunInfo, tags Tags) RunRequest

type State

type State string
const (
	StateInvalid      State = ""
	StateReserved     State = "reserved"
	StateInitializing State = "initializing"
	StateCreated      State = "created"
	StateRunning      State = "running"
	StateCompleted    State = "completed"
)

type Tags

type Tags map[string]string

func (Tags) Add

func (t Tags) Add(other Tags)

func (Tags) Copy

func (t Tags) Copy() Tags

type VolumeMount

type VolumeMount struct {
	Driver        string                 `json:"driver"`
	VolumeId      string                 `json:"volume_id"`
	Config        map[string]interface{} `json:"config"`
	ContainerPath string                 `json:"container_path"`
	Mode          BindMountMode          `json:"mode"`
}

type WorkPoolSettings

type WorkPoolSettings struct {
	CreateWorkPoolSize  int
	DeleteWorkPoolSize  int
	ReadWorkPoolSize    int
	MetricsWorkPoolSize int
}

Directories

Path Synopsis
containerstore/containerstorefakes
Code generated by counterfeiter.
Code generated by counterfeiter.
event/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
log_streamer/fake_log_streamer
Code generated by counterfeiter.
Code generated by counterfeiter.
steps/fakes
This file was generated by counterfeiter
This file was generated by counterfeiter
transformer/faketransformer
Code generated by counterfeiter.
Code generated by counterfeiter.
uploader/fake_uploader
This file was generated by counterfeiter
This file was generated by counterfeiter
Code generated by counterfeiter.
Code generated by counterfeiter.
Package gardenhealth contains logic to periodically verify that basic garden container functionality is working.
Package gardenhealth contains logic to periodically verify that basic garden container functionality is working.
fakegardenhealth
Code generated by counterfeiter.
Code generated by counterfeiter.
fakeguidgen
Code generated by counterfeiter.
Code generated by counterfeiter.
fakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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