rep

package module
v0.1442.0 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 22 Imported by: 47

README

The Rep

Note: This repository should be imported as code.cloudfoundry.org/rep.

Vote Quimby

The Rep bids on tasks and schedules them on an associated Executor.

Reporting issues and requesting features

Please report all issues and feature requests in cloudfoundry/diego-release.

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

Run Tests

  1. First setup your GOPATH and install the necessary dependencies for running tests.
  2. Setup a MySQL server or a postgres server. Please follow these instructions.
  3. Run the tests from the root directory of the rep repo:
SQL_FLAVOR=mysql ginkgo -r -p -race

Documentation

Index

Constants

View Source
const (
	LifecycleTag  = "lifecycle"
	ResultFileTag = "result-file"
	DomainTag     = "domain"

	TaskLifecycle = "task"
	LRPLifecycle  = "lrp"

	ProcessGuidTag  = "process-guid"
	InstanceGuidTag = "instance-guid"
	ProcessIndexTag = "process-index"

	VolumeDriversTag = "volume-drivers"
	PlacementTagsTag = "placement-tags"
)
View Source
const (
	LayeringModeSingleLayer = "single-layer"
	LayeringModeTwoLayer    = "two-layer"
)
View Source
const (
	StateRoute            = "STATE"
	ContainerMetricsRoute = "ContainerMetrics"
	PerformRoute          = "PERFORM"

	UpdateLRPInstanceRoute    = "UpdateLRPInstance"
	UpdateLRPInstanceRoute_r0 = "UpdateLRPInstance_r0"
	StopLRPInstanceRoute      = "StopLRPInstance"
	CancelTaskRoute           = "CancelTask"

	SimResetRoute = "RESET"

	PingRoute     = "Ping"
	EvacuateRoute = "Evacuate"
)

Variables

View Source
var (
	ErrContainerMissingTags = errors.New("container is missing tags")
	ErrInvalidProcessIndex  = errors.New("container does not have a valid process index")
)
View Source
var ErrPreloadedRootFSNotFound = errors.New("preloaded rootfs path not found")

ErrPreloadedRootFSNotFound is returned when the given hostname of the rootFS could not be resolved if the scheme is the PreloadedRootFSScheme or the PreloadedOCIRootFSScheme. This isn't the error for when the actual path on the system could not be found.

View Source
var ErrorIncompatibleRootfs = errors.New("rootfs not found")
View Source
var RoutesLocalhostOnly = NewRoutes(false)
View Source
var RoutesNetworkAccessible = NewRoutes(true)

Functions

func ActualLRPInstanceKeyFromContainer

func ActualLRPInstanceKeyFromContainer(container executor.Container, cellID string) (*models.ActualLRPInstanceKey, error)

func ActualLRPKeyFromTags

func ActualLRPKeyFromTags(tags executor.Tags) (*models.ActualLRPKey, error)

func ActualLRPNetInfoFromContainer

func ActualLRPNetInfoFromContainer(container executor.Container) (*models.ActualLRPNetInfo, error)

func ConvertCachedDependencies added in v0.1442.0

func ConvertCachedDependencies(modelDeps []*models.CachedDependency) []executor.CachedDependency

func ConvertCachedDependency added in v0.1442.0

func ConvertCachedDependency(modelDep *models.CachedDependency) executor.CachedDependency

func ConvertPortMappings

func ConvertPortMappings(containerPorts []uint32) []executor.PortMapping

func ConvertPreloadedRootFS added in v0.1442.0

func ConvertPreloadedRootFS(rootFS string, imageLayers []*models.ImageLayer, layeringMode string) (string, []*models.ImageLayer)

ConvertPreloadedRootFS takes in a rootFS URL and a list of image layers and in most cases just returns the same rootFS URL and list of image layers.

In the case where all of the following are true:

  • layeringMode == LayeringModeTwoLayer
  • the rootfs URL has a `preloaded` scheme
  • the list of image layers contains at least one image layer that has an `exclusive` layer type, `tgz` media type, and a `sha256` digest algorithm.

then the rootfs URL will be converted to have a `preloaded+layer` scheme and a query string that references the first image layer that matches all of those restrictions. This image layer will also be removed from the list.

func LRPContainerGuid

func LRPContainerGuid(processGuid, instanceGuid string) string

func NewRoutes added in v0.1442.0

func NewRoutes(networkAccessible bool) rata.Routes

Types

type ArbitraryRootFSProvider

type ArbitraryRootFSProvider struct{}

func (ArbitraryRootFSProvider) MarshalJSON

func (provider ArbitraryRootFSProvider) MarshalJSON() ([]byte, error)

func (ArbitraryRootFSProvider) Match

func (ArbitraryRootFSProvider) Type

type CellState

type CellState struct {
	RepURL                  string `json:"rep_url"`
	CellID                  string `json:"cell_id"`
	CellIndex               int    `json:"cell_index"`
	RootFSProviders         RootFSProviders
	AvailableResources      Resources
	TotalResources          Resources
	LRPs                    []LRP
	Tasks                   []Task
	StartingContainerCount  int
	Zone                    string
	Evacuating              bool
	VolumeDrivers           []string
	PlacementTags           []string
	OptionalPlacementTags   []string
	ProxyMemoryAllocationMB int
}

func NewCellState

func NewCellState(
	cellID string,
	cellIndex int,
	repURL string,
	root RootFSProviders,
	avail Resources,
	total Resources,
	lrps []LRP,
	tasks []Task,
	zone string,
	startingContainerCount int,
	isEvac bool,
	volumeDrivers []string,
	placementTags []string,
	optionalPlacementTags []string,
	proxyMemoryAllocation int,
) CellState

func (*CellState) AddLRP

func (c *CellState) AddLRP(lrp *LRP)

func (*CellState) AddTask

func (c *CellState) AddTask(task *Task)

func (CellState) ComputeScore

func (c CellState) ComputeScore(res *Resource, startingContainerWeight float64) float64

func (*CellState) MatchPlacementTags added in v0.1442.0

func (c *CellState) MatchPlacementTags(desiredPlacementTags []string) bool

func (*CellState) MatchRootFS

func (c *CellState) MatchRootFS(rootfs string) bool

func (*CellState) MatchVolumeDrivers added in v0.1442.0

func (c *CellState) MatchVolumeDrivers(volumeDrivers []string) bool

func (*CellState) ResourceMatch

func (c *CellState) ResourceMatch(res *Resource) error

type Client

type Client interface {
	State(logger lager.Logger) (CellState, error)
	Perform(logger lager.Logger, work Work) (Work, error)
	UpdateLRPInstance(logger lager.Logger, update LRPUpdate) error
	StopLRPInstance(logger lager.Logger, key models.ActualLRPKey, instanceKey models.ActualLRPInstanceKey) error
	CancelTask(logger lager.Logger, taskGuid string) error
	SetStateClient(stateClient *http.Client)
	StateClientTimeout() time.Duration
}

type ClientFactory

type ClientFactory interface {
	CreateClient(address, url, traceID string) (Client, error)
}

func NewClientFactory

func NewClientFactory(httpClient, stateClient *http.Client, tlsConfig *TLSConfig) (ClientFactory, error)

type ContainerMetricsCollection added in v0.1442.0

type ContainerMetricsCollection struct {
	CellID string       `json:"cell_id"`
	LRPs   []LRPMetric  `json:"lrps"`
	Tasks  []TaskMetric `json:"tasks"`
}

type ContainerMetricsProvider added in v0.1442.0

type ContainerMetricsProvider interface {
	Metrics() map[string]*containermetrics.CachedContainerMetrics
}

type FixedSetRootFSProvider

type FixedSetRootFSProvider struct {
	FixedSet StringSet
}

func NewFixedSetRootFSProvider

func NewFixedSetRootFSProvider(rootfses ...string) FixedSetRootFSProvider

func (FixedSetRootFSProvider) MarshalJSON

func (provider FixedSetRootFSProvider) MarshalJSON() ([]byte, error)

func (FixedSetRootFSProvider) Match

func (provider FixedSetRootFSProvider) Match(rootfs url.URL) bool

func (FixedSetRootFSProvider) Type

func (*FixedSetRootFSProvider) UnmarshalJSON

func (provider *FixedSetRootFSProvider) UnmarshalJSON(payload []byte) error

type InsufficientResourcesError added in v0.1442.0

type InsufficientResourcesError struct {
	Problems map[string]struct{}
}

func (InsufficientResourcesError) Error added in v0.1442.0

type LRP

type LRP struct {
	InstanceGUID string `json:"instance_guid"`
	models.ActualLRPKey
	PlacementConstraint
	Resource
	State string `json:"state"`
}

func NewLRP

func NewLRP(instanceGUID string, key models.ActualLRPKey, res Resource, pc PlacementConstraint) LRP

func (*LRP) Copy

func (lrp *LRP) Copy() LRP

func (*LRP) Identifier

func (lrp *LRP) Identifier() string

type LRPMetric added in v0.1442.0

type LRPMetric struct {
	InstanceGUID string `json:"instance_guid"`
	ProcessGUID  string `json:"process_guid"`
	Index        int32  `json:"index"`
	containermetrics.CachedContainerMetrics
}

type LRPUpdate added in v0.1442.0

type LRPUpdate struct {
	InstanceGUID string `json:"instance_guid"`
	models.ActualLRPKey
	InternalRoutes internalroutes.InternalRoutes `json:"internal_routes"`
	MetricTags     map[string]string             `json:"metric_tags"`
}

func NewLRPUpdate added in v0.1442.0

func NewLRPUpdate(instanceGUID string, key models.ActualLRPKey, internalRoutes internalroutes.InternalRoutes, metricTags map[string]string) LRPUpdate

type PlacementConstraint added in v0.1442.0

type PlacementConstraint struct {
	PlacementTags []string
	VolumeDrivers []string
	RootFs        string
}

func NewPlacementConstraint added in v0.1442.0

func NewPlacementConstraint(rootFs string, placementTags, volumeDrivers []string) PlacementConstraint

func (*PlacementConstraint) Valid added in v0.1442.0

func (p *PlacementConstraint) Valid() bool

type Resource

type Resource struct {
	MemoryMB int32
	DiskMB   int32
	MaxPids  int32
}

func NewResource

func NewResource(memoryMb, diskMb int32, maxPids int32) Resource

func (*Resource) Copy

func (r *Resource) Copy() Resource

func (*Resource) Valid added in v0.1442.0

func (r *Resource) Valid() bool

type Resources

type Resources struct {
	MemoryMB   int32
	DiskMB     int32
	Containers int
}

func NewResources

func NewResources(memoryMb, diskMb int32, containerCount int) Resources

func (*Resources) ComputeScore

func (r *Resources) ComputeScore(total *Resources) float64

func (*Resources) Copy

func (r *Resources) Copy() Resources

func (*Resources) Subtract

func (r *Resources) Subtract(res *Resource)

type RootFSProvider

type RootFSProvider interface {
	Type() RootFSProviderType
	Match(url.URL) bool
}

type RootFSProviderType

type RootFSProviderType string
const (
	RootFSProviderTypeArbitrary RootFSProviderType = "arbitrary"
	RootFSProviderTypeFixedSet  RootFSProviderType = "fixed_set"
)

type RootFSProviders

type RootFSProviders map[string]RootFSProvider

func (RootFSProviders) Copy

func (RootFSProviders) Match

func (p RootFSProviders) Match(rootFS url.URL) bool

func (*RootFSProviders) UnmarshalJSON

func (providers *RootFSProviders) UnmarshalJSON(payload []byte) error

type RunRequestConversionHelper added in v0.1442.0

type RunRequestConversionHelper struct {
	ECRHelper ecrhelper.ECRHelper
}

func (RunRequestConversionHelper) NewRunRequestFromDesiredLRP added in v0.1442.0

func (rrch RunRequestConversionHelper) NewRunRequestFromDesiredLRP(
	containerGuid string,
	desiredLRP *models.DesiredLRP,
	lrpKey *models.ActualLRPKey,
	lrpInstanceKey *models.ActualLRPInstanceKey,
	stackPathMap StackPathMap,
	layeringMode string,
) (executor.RunRequest, error)

func (RunRequestConversionHelper) NewRunRequestFromTask added in v0.1442.0

func (rrch RunRequestConversionHelper) NewRunRequestFromTask(task *models.Task, stackPathMap StackPathMap, layeringMode string) (executor.RunRequest, error)

type SimClient

type SimClient interface {
	Client
	Reset() error
}

type StackPathMap

type StackPathMap map[string]string

StackPathMap maps aliases to rootFS paths on the system.

func (StackPathMap) PathForRootFS added in v0.1442.0

func (m StackPathMap) PathForRootFS(rootFS string) (string, error)

PathForRootFS resolves the hostname portion of the RootFS URL to the actual path to the preloaded rootFS on the system according to the StackPathMap

type StringSet

type StringSet map[string]struct{}

func NewStringSet

func NewStringSet(entries ...string) StringSet

func (StringSet) Contains

func (set StringSet) Contains(candidate string) bool

type TLSConfig added in v0.1442.0

type TLSConfig struct {
	RequireTLS                    bool
	CertFile, KeyFile, CaCertFile string
	ClientCacheSize               int // the tls client cache size, 0 means use golang default value
}

capture the behavior described in the comment of this story https://www.pivotaltracker.com/story/show/130664747/comments/152863773

type Task

type Task struct {
	TaskGuid string
	Domain   string
	PlacementConstraint
	Resource
	State  models.Task_State `json:"state"`
	Failed bool              `json:"failed"`
}

func NewTask

func NewTask(guid string, domain string, res Resource, pc PlacementConstraint) Task

func (Task) Copy

func (task Task) Copy() Task

func (*Task) Identifier

func (task *Task) Identifier() string

type TaskMetric added in v0.1442.0

type TaskMetric struct {
	TaskGUID string `json:"task_guid"`
	containermetrics.CachedContainerMetrics
}

type Work

type Work struct {
	LRPs   []LRP
	Tasks  []Task
	CellID string `json:"cell_id,omitempty"`
}

Directories

Path Synopsis
auctioncellrepfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
cmd
rep
evacuation_context/fake_evacuation_context
Code generated by counterfeiter.
Code generated by counterfeiter.
generator creates operations for container processing
generator creates operations for container processing
fake_generator
Code generated by counterfeiter.
Code generated by counterfeiter.
internal/fake_internal
Code generated by counterfeiter.
Code generated by counterfeiter.
handlersfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
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