dockerstate

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2019 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DockerTaskEngineState

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

DockerTaskEngineState keeps track of all mappings between tasks we know about and containers docker runs It contains a mutex that can be used to ensure out-of-date state cannot be accessed before an update comes and to ensure multiple goroutines can safely work with it.

The methods on it will acquire the read lock, but not all acquire the write lock (sometimes it is up to the caller). This is because the write lock for containers should encapsulate the creation of the resource as well as adding, and creating the resource (docker container) is outside the scope of this package. This isn't ideal usage and I'm open to this being reworked/improved.

Some information is duplicated in the interest of having efficient lookups

func (*DockerTaskEngineState) AddContainer

func (state *DockerTaskEngineState) AddContainer(container *apicontainer.DockerContainer, task *apitask.Task)

AddContainer adds a container to the state. If the container has been added with only a name and no docker-id, this updates the state to include the docker id

func (*DockerTaskEngineState) AddENIAttachment added in v1.14.5

func (state *DockerTaskEngineState) AddENIAttachment(eniAttachment *apieni.ENIAttachment)

AddENIAttachment adds the eni into the state

func (*DockerTaskEngineState) AddImageState added in v1.13.0

func (state *DockerTaskEngineState) AddImageState(imageState *image.ImageState)

AddImageState adds an image.ImageState to be stored

func (*DockerTaskEngineState) AddTask added in v1.1.0

func (state *DockerTaskEngineState) AddTask(task *apitask.Task)

AddTask adds a new task to the state

func (*DockerTaskEngineState) AddTaskIPAddress added in v1.17.0

func (state *DockerTaskEngineState) AddTaskIPAddress(addr string, taskARN string)

AddTaskIPAddress adds ip adddress for a task arn into the state

func (*DockerTaskEngineState) AllENIAttachments added in v1.14.5

func (state *DockerTaskEngineState) AllENIAttachments() []*apieni.ENIAttachment

AllENIAttachments returns all the enis managed by ecs on the instance

func (*DockerTaskEngineState) AllImageStates added in v1.13.0

func (state *DockerTaskEngineState) AllImageStates() []*image.ImageState

AllImageStates returns all of the image.ImageStates

func (*DockerTaskEngineState) AllTasks

func (state *DockerTaskEngineState) AllTasks() []*apitask.Task

AllTasks returns all of the tasks

func (*DockerTaskEngineState) ContainerByID added in v1.14.1

func (state *DockerTaskEngineState) ContainerByID(id string) (*apicontainer.DockerContainer, bool)

ContainerByID returns an apicontainer.DockerContainer for a given container ID

func (*DockerTaskEngineState) ContainerMapByArn

func (state *DockerTaskEngineState) ContainerMapByArn(arn string) (map[string]*apicontainer.DockerContainer, bool)

ContainerMapByArn returns a map of containers belonging to a particular task ARN

func (*DockerTaskEngineState) DockerIDByV3EndpointID added in v1.21.0

func (state *DockerTaskEngineState) DockerIDByV3EndpointID(v3EndpointID string) (string, bool)

DockerIDByV3EndpointID returns a docker ID for a given v3 endpoint ID

func (*DockerTaskEngineState) ENIByMac added in v1.14.5

func (state *DockerTaskEngineState) ENIByMac(mac string) (*apieni.ENIAttachment, bool)

ENIByMac returns the eni object that match the give mac address

func (*DockerTaskEngineState) GetAllContainerIDs added in v1.14.2

func (state *DockerTaskEngineState) GetAllContainerIDs() []string

GetAllContainerIDs returns all of the Container Ids

func (*DockerTaskEngineState) GetTaskByIPAddress added in v1.17.0

func (state *DockerTaskEngineState) GetTaskByIPAddress(addr string) (string, bool)

GetTaskByIPAddress gets the task arn for an IP address

func (*DockerTaskEngineState) MarshalJSON

func (state *DockerTaskEngineState) MarshalJSON() ([]byte, error)

func (*DockerTaskEngineState) RemoveENIAttachment added in v1.14.5

func (state *DockerTaskEngineState) RemoveENIAttachment(mac string)

RemoveENIAttachment removes the eni from state and stop managing

func (*DockerTaskEngineState) RemoveImageState added in v1.13.0

func (state *DockerTaskEngineState) RemoveImageState(imageState *image.ImageState)

RemoveImageState removes an image.ImageState

func (*DockerTaskEngineState) RemoveTask

func (state *DockerTaskEngineState) RemoveTask(task *apitask.Task)

RemoveTask removes a task from this state. It removes all containers and other associated metadata. It does acquire the write lock.

func (*DockerTaskEngineState) Reset added in v1.14.4

func (state *DockerTaskEngineState) Reset()

Reset resets all the states

func (*DockerTaskEngineState) TaskARNByV3EndpointID added in v1.21.0

func (state *DockerTaskEngineState) TaskARNByV3EndpointID(v3EndpointID string) (string, bool)

TaskARNByV3EndpointID returns a taskARN for a given v3 endpoint ID

func (*DockerTaskEngineState) TaskByArn

func (state *DockerTaskEngineState) TaskByArn(arn string) (*apitask.Task, bool)

TaskByArn returns a task for a given ARN

func (*DockerTaskEngineState) TaskByID added in v1.14.1

func (state *DockerTaskEngineState) TaskByID(cid string) (*apitask.Task, bool)

TaskByID retrieves the task of a given docker container id

func (*DockerTaskEngineState) TaskByShortID added in v1.14.2

func (state *DockerTaskEngineState) TaskByShortID(cid string) ([]*apitask.Task, bool)

TaskByShortID retrieves the task of a given docker short container id

func (*DockerTaskEngineState) UnmarshalJSON

func (state *DockerTaskEngineState) UnmarshalJSON(data []byte) error

type TaskEngineState added in v1.14.1

type TaskEngineState interface {
	// AllTasks returns all of the tasks
	AllTasks() []*apitask.Task
	// AllENIAttachments returns all of the eni attachments
	AllENIAttachments() []*apieni.ENIAttachment
	// AllImageStates returns all of the image.ImageStates
	AllImageStates() []*image.ImageState
	// GetAllContainerIDs returns all of the Container Ids
	GetAllContainerIDs() []string
	// ContainerByID returns an apicontainer.DockerContainer for a given container ID
	ContainerByID(id string) (*apicontainer.DockerContainer, bool)
	// ContainerMapByArn returns a map of containers belonging to a particular task ARN
	ContainerMapByArn(arn string) (map[string]*apicontainer.DockerContainer, bool)
	// TaskByShortID retrieves the task of a given docker short container id
	TaskByShortID(cid string) ([]*apitask.Task, bool)
	// TaskByID returns an apitask.Task for a given container ID
	TaskByID(cid string) (*apitask.Task, bool)
	// TaskByArn returns a task for a given ARN
	TaskByArn(arn string) (*apitask.Task, bool)
	// AddTask adds a task to the state to be stored
	AddTask(task *apitask.Task)
	// AddContainer adds a container to the state to be stored for a given task
	AddContainer(container *apicontainer.DockerContainer, task *apitask.Task)
	// AddImageState adds an image.ImageState to be stored
	AddImageState(imageState *image.ImageState)
	// AddENIAttachment adds an eni attachment from acs to be stored
	AddENIAttachment(eni *apieni.ENIAttachment)
	// RemoveENIAttachment removes an eni attachment to stop tracking
	RemoveENIAttachment(mac string)
	// ENIByMac returns the specific ENIAttachment of the given mac address
	ENIByMac(mac string) (*apieni.ENIAttachment, bool)
	// RemoveTask removes a task from the state
	RemoveTask(task *apitask.Task)
	// Reset resets all the fileds in the state
	Reset()
	// RemoveImageState removes an image.ImageState
	RemoveImageState(imageState *image.ImageState)
	// AddTaskIPAddress adds ip adddress for a task arn into the state
	AddTaskIPAddress(addr string, taskARN string)
	// GetTaskByIPAddress gets the task arn for an IP address
	GetTaskByIPAddress(addr string) (string, bool)
	// DockerIDByV3EndpointID returns a docker ID for a given v3 endpoint ID
	DockerIDByV3EndpointID(v3EndpointID string) (string, bool)
	// TaskARNByV3EndpointID returns a taskARN for a given v3 endpoint ID
	TaskARNByV3EndpointID(v3EndpointID string) (string, bool)

	json.Marshaler
	json.Unmarshaler
}

TaskEngineState keeps track of all mappings between tasks we know about and containers docker runs

func NewTaskEngineState added in v1.14.1

func NewTaskEngineState() TaskEngineState

NewTaskEngineState returns a new TaskEngineState

Directories

Path Synopsis
Package mock_dockerstate is a generated GoMock package.
Package mock_dockerstate is a generated GoMock package.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.

Jump to

Keyboard shortcuts

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