Documentation ¶
Index ¶
- Constants
- Variables
- type AgentMessage
- type AgentShutdown
- type AgentStarted
- type ContainerFailure
- type ContainerLog
- type ContainerReattach
- type ContainerReattachAck
- type ContainerStarted
- type ContainerStateChanged
- type ContainerStatsRecord
- type ContainerStopped
- type ExitCode
- type FailureType
- type GetRPConfig
- type GetRPResponse
- type ID
- type MasterInfo
- type MasterMessage
- type MasterSetAgentOptions
- type RunMessage
- type SignalContainer
- type StartContainer
- type TelemetryInfo
Constants ¶
const ( // AgentReconnectAttempts is the max attempts an agent has to reconnect. AgentReconnectAttempts = 5 // AgentReconnectBackoffValue in seconds. AgentReconnectBackoffValue = 5 // AgentReconnectBackoff is the time between attempts, with the exception of the first. AgentReconnectBackoff = AgentReconnectBackoffValue * time.Second // AgentReconnectWait is the max time the master should wait for an agent before considering // it dead. The agent waits (AgentReconnectWait - AgentReconnectBackoff) before stopping // attempts and AgentReconnectWait before crashing. AgentReconnectWait = AgentReconnectAttempts * AgentReconnectBackoff )
const (
// SuccessExitCode is the 0 zero value exit code.
SuccessExitCode = 0
)
Variables ¶
var ErrAgentMustReconnect = errors.New("agent is past reconnect period, it must restart")
ErrAgentMustReconnect is the error returned by the master when the agent must exit and reconnect.
Functions ¶
This section is empty.
Types ¶
type AgentMessage ¶
type AgentMessage struct { MasterSetAgentOptions *MasterSetAgentOptions StartContainer *StartContainer SignalContainer *SignalContainer AgentShutdown *AgentShutdown }
AgentMessage is a union type for all messages sent to agents.
type AgentShutdown ¶
type AgentShutdown struct {
ErrMsg string
}
AgentShutdown is an explicit message from master to agent it should shutdown itself.
type AgentStarted ¶
type AgentStarted struct { Version string Devices []device.Device ContainersReattached []ContainerReattachAck }
AgentStarted notifies the master that the agent has started up.
type ContainerFailure ¶
type ContainerFailure struct { FailureType FailureType ErrMsg string ExitCode *ExitCode }
ContainerFailure holds the reason why a container did not complete successfully.
func NewContainerExit ¶
func NewContainerExit(code ExitCode) *ContainerFailure
NewContainerExit returns a container failure with the encoded exit code. If the exit code is a the zero value, no failure is returned.
func NewContainerFailure ¶
func NewContainerFailure(failureType FailureType, err error) *ContainerFailure
NewContainerFailure returns a container failure wrapping the provided error. If the error is nil, a stack trace is provided instead.
func (ContainerFailure) Error ¶
func (c ContainerFailure) Error() string
type ContainerLog ¶
type ContainerLog struct { ContainerID cproto.ID Timestamp time.Time Level *string PullMessage *string RunMessage *RunMessage AuxMessage *string Source *string AgentID *string }
ContainerLog notifies the master that a new log message is available for the container.
type ContainerReattach ¶
ContainerReattach is a struct describing containers that can be reattached.
type ContainerReattachAck ¶
type ContainerReattachAck struct { Container cproto.Container Failure *ContainerFailure }
ContainerReattachAck is a struct describing containers reattachment success.
func FromContainerStateChanged ¶
func FromContainerStateChanged(csc *ContainerStateChanged) *ContainerReattachAck
FromContainerStateChanged forms a container reattach ack from a state change message.
type ContainerStarted ¶
type ContainerStarted struct { ProxyAddress string ContainerInfo types.ContainerJSON }
ContainerStarted notifies the master that the agent has started a container.
func (ContainerStarted) Addresses ¶
func (c ContainerStarted) Addresses() []cproto.Address
Addresses calculates the address of containers and hosts based on the container started information.
func (ContainerStarted) String ¶
func (c ContainerStarted) String() string
type ContainerStateChanged ¶
type ContainerStateChanged struct { Container cproto.Container ContainerStarted *ContainerStarted ContainerStopped *ContainerStopped }
ContainerStateChanged notifies the master that the agent transitioned the container state.
type ContainerStatsRecord ¶
ContainerStatsRecord notifies the master that about the container stats of docker. For now this carries stats of docker image pull.
type ContainerStopped ¶
type ContainerStopped struct {
Failure *ContainerFailure
}
ContainerStopped notifies the master that a container was stopped on the agent.
func ContainerError ¶
func ContainerError(failureType FailureType, err error) ContainerStopped
ContainerError returns a container failure wrapping the provided error. If the error is nil, a stack trace is provided instead.
func ContainerExited ¶
func ContainerExited(code ExitCode) ContainerStopped
ContainerExited returns a container failure with the encoded exit code. If the exit code is a the zero value, no failure is returned.
func (ContainerStopped) String ¶
func (c ContainerStopped) String() string
type FailureType ¶
type FailureType string
FailureType denotes the type of failure that resulted in the container stopping. Each FailureType must be handled by ./internal/task/allocation.go.
const ( // ContainerFailed denotes that the container ran but failed with a non-zero exit code. ContainerFailed FailureType = "container failed with non-zero exit code" // ContainerAborted denotes the container was canceled before it was started. ContainerAborted FailureType = "container was aborted before it started" // ContainerMissing denotes the container was missing when the master asked about it. ContainerMissing FailureType = "request for action on unknown container" // TaskAborted denotes that the task was canceled before it was started. TaskAborted FailureType = "task was aborted before the task was started" // TaskError denotes that the task failed without an associated exit code. TaskError FailureType = "task failed without an associated exit code" // AgentFailed denotes that the agent failed while the container was running. AgentFailed FailureType = "agent failed while the container was running" // RestoreError denotes that we failed to restore the container after some agent failure. RestoreError FailureType = "container failed to restore after agent failure" // AgentError denotes that the agent failed to launch the container. AgentError FailureType = "agent failed to launch the container" )
type GetRPConfig ¶
type GetRPConfig struct{}
GetRPConfig is a request from agent to RP actor for some config options.
type GetRPResponse ¶
GetRPResponse is a response to the previous request.
type MasterInfo ¶
type MasterInfo struct { Version string `json:"version"` MasterID string `json:"master_id"` ClusterID string `json:"cluster_id"` ClusterName string `json:"cluster_name"` Telemetry TelemetryInfo `json:"telemetry"` }
MasterInfo contains the master information that the agent has connected to.
type MasterMessage ¶
type MasterMessage struct { AgentStarted *AgentStarted ContainerStateChanged *ContainerStateChanged ContainerLog *ContainerLog ContainerStatsRecord *ContainerStatsRecord }
MasterMessage is a union type for all messages sent from agents.
type MasterSetAgentOptions ¶
type MasterSetAgentOptions struct { MasterInfo MasterInfo LoggingOptions model.LoggingConfig ContainersToReattach []ContainerReattach }
MasterSetAgentOptions is the first message sent to an agent by the master. It lets the agent know to update its configuration with the options in this message. This is generally useful for configurations that are not _agent_ specific but cluster-wide.
type RunMessage ¶
RunMessage holds the message sent by the container in the run phase.
type SignalContainer ¶
SignalContainer notifies the agent to send the requested signal to the container.
type StartContainer ¶
StartContainer notifies the agent to start a container with the provided spec.