pod

package
v0.0.0-...-57dc925 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPodUsage

func GetPodUsage(spec []specPhase, executedSeconds int32) v1.ResourceList

Types

type Metrics

type Metrics struct {
	ResourceRequest v1.ResourceList
	ResourceLimit   v1.ResourceList
	ResourceUsage   v1.ResourceList
	Runtime         int32

	BoundAt         clock.Clock
	Node            string
	ExecutedSeconds int32

	Priority int32
	Status   Status
}

Metrics is a metrics of a pod at one time point.

type Pod

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

Pod represents a simulated pod.

func NewPod

func NewPod(pod *v1.Pod, boundAt clock.Clock, status Status, node string) (*Pod, error)

NewPod creates a pod with the given v1.Pod, the clock at which the pod was bound to a node, and the pod's status. Returns error if fails to parse the simulation spec of the pod.

func (*Pod) BuildStatus

func (pod *Pod) BuildStatus(clock clock.Clock) v1.PodStatus

BuildStatus builds a status of this Pod at the given clock, assuming that this Pod has not been deleted (but it can be terminating).

func (*Pod) Delete

func (pod *Pod) Delete(clock clock.Clock)

Delete starts to delete this Pod.

func (*Pod) FreezeUsage

func (pod *Pod) FreezeUsage(clock clock.Clock)

func (*Pod) HasFailedToStart

func (pod *Pod) HasFailedToStart() bool

HasFailedToStart returns whether this Pod has failed to start to a node.

func (*Pod) IsDeleted

func (pod *Pod) IsDeleted(clk clock.Clock) bool

IsDeleted returns whether this Pod has been deleted.

func (*Pod) IsRunning

func (pod *Pod) IsRunning(clock clock.Clock) bool

IsRunning returns whether this Pod is running at the given clock. Returns false if this Pod has failed to start.

func (*Pod) IsTerminated

func (pod *Pod) IsTerminated(clock clock.Clock) bool

IsTerminated returns whether this Pod is terminated at the clock. If this Pod failed to start, false is returned.

func (*Pod) IsTerminating

func (pod *Pod) IsTerminating(clock clock.Clock) bool

IsTerminating returns whether this Pod is terminating (i.e. in its grace period).

func (*Pod) Metrics

func (pod *Pod) Metrics(clock clock.Clock) Metrics

Metrics returns the Metrics of this Pod at the given clock.

func (*Pod) ResourceUsage

func (pod *Pod) ResourceUsage(clock clock.Clock) v1.ResourceList

ResourceUsage returns resource usage of this Pod at the given clock.

func (*Pod) ToV1

func (pod *Pod) ToV1() *v1.Pod

ToV1 returns v1.Pod representation of this Pod.

func (*Pod) TotalResourceLimits

func (pod *Pod) TotalResourceLimits() v1.ResourceList

TotalResourceLimits extracts the total amount of resource limits of this Pod.

func (*Pod) TotalResourceRequests

func (pod *Pod) TotalResourceRequests() v1.ResourceList

TotalResourceRequests extracts the total amount of resource requested by this Pod.

type Status

type Status int

Status represents status of a Pod.

const (
	// Ok indicates that the pod has been successfully started on a node.
	// Whether the pod is running or has spontaneously terminated is determined by its total
	// execution time and the clock.
	Ok Status = iota

	// Deleted indicates that the pod has been deleted from the cluster.
	// Whether the pod is terminating (i.e., in its grace period) or has been deleted is determined
	// by the length of its grace period and the clock.
	Deleted

	// OverCapacity indicates that the pod failed to start due to over capacity.
	OverCapacity
)

func (Status) MarshalJSON

func (status Status) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (Status) String

func (status Status) String() string

String implements Stringer interface.

Jump to

Keyboard shortcuts

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