podstatus

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsulStore

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

func NewConsul

func NewConsul(statusStore statusstore.Store, namespace statusstore.Namespace) ConsulStore

TODO: this pod store is coupled with the PodStatus struct, which represents the book keeping that the preparer does about a pod. In other words it only makes sense if the namespace is consul.PreparerPodStatusNamespace. We should probably take namespace out of all these APIs and use that constant instead.

func (ConsulStore) CAS

func (c ConsulStore) CAS(ctx context.Context, key types.PodUniqueKey, status PodStatus, modifyIndex uint64) error

func (ConsulStore) Delete

func (c ConsulStore) Delete(podUniqueKey types.PodUniqueKey) error

func (ConsulStore) Get

func (ConsulStore) GetStatusFromIndex

func (c ConsulStore) GetStatusFromIndex(index podstore.PodIndex) (PodStatus, *api.QueryMeta, error)

func (ConsulStore) List

func (c ConsulStore) List() (map[types.PodUniqueKey]PodStatus, error)

List lists all of the pod status entries in consul.

func (ConsulStore) MutateStatus

func (c ConsulStore) MutateStatus(ctx context.Context, key types.PodUniqueKey, mutator func(PodStatus) (PodStatus, error)) error

Convenience function for only mutating a part of the status structure. First, the status is retrieved and the consul ModifyIndex is read. The status is then passed to a mutator function, and then the new status is written back to consul using a CAS operation, guaranteeing that nothing else about the status changed.

func (ConsulStore) Set

func (c ConsulStore) Set(key types.PodUniqueKey, status PodStatus) error

func (ConsulStore) SetLastExit

func (c ConsulStore) SetLastExit(ctx context.Context, podUniqueKey types.PodUniqueKey, launchableID launch.LaunchableID, entryPoint string, exitStatus ExitStatus) error

A helper method for updating the LastExit field of one of the processes in a pod. Searches through p.ProcessStatuses for a process matching the launchable ID and launchableScriptName, and mutates its LastExit if found. If not found, a new process is added.

func (ConsulStore) WaitForStatus

func (c ConsulStore) WaitForStatus(key types.PodUniqueKey, waitIndex uint64) (PodStatus, *api.QueryMeta, error)

type ExitStatus

type ExitStatus struct {
	ExitTime   time.Time `json:"time"`
	ExitCode   int       `json:"exit_code"`
	ExitStatus int       `json:"exit_status"`
}

Encapsulates information relating to the exit of a process.

type PodState

type PodState string
const (
	// Signifies that the pod has been launched
	PodLaunched PodState = "launched"

	// Signifies that the pod has been unscheduled and removed from the machine
	PodRemoved PodState = "removed"

	// PodFailed denotes a pod that failed. The definition of "failed" is
	// complex as there are potentially many processes spawned by a pod,
	// some of which may be configured to restart on failure. As a result
	// of this, it is the responsibility of whatever system scheduled a pod
	// in the first place to mark a pod as failed. It is not done within P2
	// itself. This constant is only defined for convenience.
	PodFailed PodState = "failed"
)

func (PodState) String

func (p PodState) String() string

type PodStatus

type PodStatus struct {
	ProcessStatuses []ProcessStatus `json:"process_status"`
	PodStatus       PodState        `json:"status"`

	// String representing the pod manifest for the running pod. Will be
	// empty if it hasn't yet been launched
	Manifest string `json:"manifest"`
}

Encapsulates the state of all processes running in a pod.

type ProcessStatus

type ProcessStatus struct {
	LaunchableID launch.LaunchableID `json:"launchable_id"`
	EntryPoint   string              `json:"entry_point"`
	LastExit     *ExitStatus         `json:"last_exit"`
}

Encapsulates information regarding the state of a process. Currently only information about the last exit is exposed.

Jump to

Keyboard shortcuts

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