container

package
v0.0.0-...-2600015 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: AGPL-3.0, Apache-2.0, CC-BY-SA-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	RequestAndDecode(dst interface{}, method, path string, body io.Reader, params interface{}) error
}

An APIClient performs Arvados API requests. It is typically an *arvados.Client.

type Queue

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

A Queue is an interface to an Arvados cluster's container database. It presents only the containers that are eligible to be run by, are already being run by, or have recently been run by the present dispatcher.

The Entries, Get, and Forget methods do not block: they return immediately, using cached data.

The updating methods (Cancel, Lock, Unlock, Update) do block: they return only after the operation has completed.

A Queue's Update method should be called periodically to keep the cache up to date.

func NewQueue

func NewQueue(logger logrus.FieldLogger, reg *prometheus.Registry, chooseType typeChooser, client APIClient) *Queue

NewQueue returns a new Queue. When a new container appears in the Arvados cluster's queue during Update, chooseType will be called to assign an appropriate arvados.InstanceType for the queue entry.

func (*Queue) Cancel

func (cq *Queue) Cancel(uuid string) error

Cancel cancels the given container.

func (*Queue) Entries

func (cq *Queue) Entries() (entries map[string]QueueEnt, threshold time.Time)

Entries returns all cache entries, keyed by container UUID.

The returned threshold indicates the maximum age of any cached data returned in the map. This makes it possible for a scheduler to determine correctly the outcome of a remote process that updates container state. It must first wait for the remote process to exit, then wait for the Queue to start and finish its next Update -- i.e., it must wait until threshold > timeProcessExited.

func (*Queue) Forget

func (cq *Queue) Forget(uuid string)

Forget drops the specified container from the cache. It should be called on finalized containers to avoid leaking memory over time. It is a no-op if the indicated container is not in a finalized state.

func (*Queue) Get

func (cq *Queue) Get(uuid string) (arvados.Container, bool)

Get returns the (partial) Container record for the specified container. Like a map lookup, its second return value is false if the specified container is not in the Queue.

func (*Queue) Lock

func (cq *Queue) Lock(uuid string) error

Lock acquires the dispatch lock for the given container.

func (*Queue) Subscribe

func (cq *Queue) Subscribe() <-chan struct{}

Subscribe returns a channel that becomes ready to receive when an entry in the Queue is updated.

ch := q.Subscribe()
defer q.Unsubscribe(ch)
for range ch {
	// ...
}

func (*Queue) Unlock

func (cq *Queue) Unlock(uuid string) error

Unlock releases the dispatch lock for the given container.

func (*Queue) Unsubscribe

func (cq *Queue) Unsubscribe(ch <-chan struct{})

Unsubscribe stops sending updates to the given channel. See Subscribe.

func (*Queue) Update

func (cq *Queue) Update() error

Update refreshes the cache from the Arvados API. It adds newly queued containers, and updates the state of previously queued containers.

type QueueEnt

type QueueEnt struct {
	// The container to run. Only the UUID, State, Priority,
	// RuntimeConstraints, ContainerImage, SchedulingParameters,
	// and CreatedAt fields are populated.
	Container     arvados.Container      `json:"container"`
	InstanceTypes []arvados.InstanceType `json:"instance_types"`
	FirstSeenAt   time.Time              `json:"first_seen_at"`
}

A QueueEnt is an entry in the queue, consisting of a container record and the instance type that should be used to run it.

func (*QueueEnt) String

func (c *QueueEnt) String() string

String implements fmt.Stringer by returning the queued container's UUID.

Jump to

Keyboard shortcuts

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