workload

package
v0.7.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypePod        = "pod"
	TypeJob        = "job"
	TypePyTorchJob = "pytorchjob"
	TypeGeneric    = "generic"

	AnnotationLastAppliedSpec = "okdev.io/last-applied-spec"
	AnnotationLastAppliedHash = "okdev.io/last-applied-spec-sha256"
)
View Source
const DefaultTargetContainer = "dev"

Variables

This section is empty.

Functions

func AnnotationsWithWorkload

func AnnotationsWithWorkload(base map[string]string, workloadName, apiVersion, resourceKind string) map[string]string

func ComparePodPriority

func ComparePodPriority(a, b kube.PodSummary) bool

ComparePodPriority is the canonical pod scoring function used by both runtime target selection and session view display. Pods are scored by: +8 for having a last-attach annotation, +4 for Running phase, +2 for Ready status. Ties broken by creation time (newest first), then name.

func DiscoveryLabelSelector

func DiscoveryLabelSelector(labels map[string]string) string

DiscoveryLabelSelector returns a label selector using only the session-identifying labels needed for pod discovery. This avoids passing workload-specific labels that controllers might not propagate to child pods.

func LabelsWithWorkload

func LabelsWithWorkload(base map[string]string, workloadName, resourceKind string) map[string]string

func ResolveManifestPath

func ResolveManifestPath(configPath, manifestPath string) string

Types

type ApplyClient

type ApplyClient interface {
	Apply(ctx context.Context, namespace string, manifest []byte) error
}

type DeleteClient

type DeleteClient interface {
	Delete(ctx context.Context, namespace string, kind string, name string, ignoreNotFound bool) error
	DeleteByRef(ctx context.Context, namespace string, apiVersion string, kind string, name string, ignoreNotFound bool) error
}

type GenericRuntime

type GenericRuntime struct {
	WorkloadKind        string
	ManifestPath        string
	WorkspaceMountPath  string
	SidecarImage        string
	SidecarResources    corev1.ResourceRequirements
	Tmux                bool
	PreStop             string
	TargetContainer     string
	Volumes             []corev1.Volume
	Labels              map[string]string
	Annotations         map[string]string
	Inject              []config.WorkloadInjectSpec
	LastAppliedSpecJSON string
	LastAppliedSpecHash string
	// contains filtered or unexported fields
}

func (*GenericRuntime) Apply

func (r *GenericRuntime) Apply(ctx context.Context, k ApplyClient, namespace string) error

func (*GenericRuntime) Delete

func (r *GenericRuntime) Delete(ctx context.Context, k DeleteClient, namespace string, ignoreNotFound bool) error

func (*GenericRuntime) Kind

func (r *GenericRuntime) Kind() string

func (*GenericRuntime) SelectTarget

func (r *GenericRuntime) SelectTarget(ctx context.Context, k TargetClient, namespace string) (TargetRef, error)

func (*GenericRuntime) WaitReady

func (r *GenericRuntime) WaitReady(ctx context.Context, k WaitClient, namespace string, timeout time.Duration, onProgress func(kube.PodReadinessProgress)) error

func (*GenericRuntime) WorkloadName

func (r *GenericRuntime) WorkloadName() string

func (*GenericRuntime) WorkloadRef

func (r *GenericRuntime) WorkloadRef() (string, string, string, error)

type PodRuntime

type PodRuntime struct {
	SessionName         string
	Labels              map[string]string
	Annotations         map[string]string
	PodSpec             corev1.PodSpec
	Volumes             []corev1.Volume
	WorkspaceMountPath  string
	SidecarImage        string
	SidecarResources    corev1.ResourceRequirements
	Tmux                bool
	PreStop             string
	TargetContainer     string
	LastAppliedSpecJSON string
	LastAppliedSpecHash string
}

func NewPodRuntime

func NewPodRuntime(sessionName string, labels, annotations map[string]string, podSpec corev1.PodSpec, volumes []corev1.Volume, workspaceMountPath, sidecarImage string, sidecarResources corev1.ResourceRequirements, tmux bool, preStop, targetContainer string) *PodRuntime

func (*PodRuntime) Apply

func (r *PodRuntime) Apply(ctx context.Context, k ApplyClient, namespace string) error

func (*PodRuntime) Delete

func (r *PodRuntime) Delete(ctx context.Context, k DeleteClient, namespace string, ignoreNotFound bool) error

func (*PodRuntime) Kind

func (r *PodRuntime) Kind() string

func (*PodRuntime) SelectTarget

func (r *PodRuntime) SelectTarget(ctx context.Context, k TargetClient, namespace string) (TargetRef, error)

func (*PodRuntime) WaitReady

func (r *PodRuntime) WaitReady(ctx context.Context, k WaitClient, namespace string, timeout time.Duration, onProgress func(kube.PodReadinessProgress)) error

func (*PodRuntime) WorkloadName

func (r *PodRuntime) WorkloadName() string

func (*PodRuntime) WorkloadRef

func (r *PodRuntime) WorkloadRef() (string, string, string, error)

type RefProvider

type RefProvider interface {
	WorkloadRef() (apiVersion string, kind string, name string, err error)
}

type Runtime

type Runtime interface {
	Kind() string
	WorkloadName() string
	Apply(ctx context.Context, k ApplyClient, namespace string) error
	Delete(ctx context.Context, k DeleteClient, namespace string, ignoreNotFound bool) error
	WaitReady(ctx context.Context, k WaitClient, namespace string, timeout time.Duration, onProgress func(kube.PodReadinessProgress)) error
	SelectTarget(ctx context.Context, k TargetClient, namespace string) (TargetRef, error)
}

type TargetClient

type TargetClient interface {
	GetPodSummary(ctx context.Context, namespace, name string) (*kube.PodSummary, error)
	ListPods(ctx context.Context, namespace string, allNamespaces bool, labelSelector string) ([]kube.PodSummary, error)
}

type TargetRef

type TargetRef struct {
	PodName   string `json:"podName"`
	Container string `json:"container"`
	Role      string `json:"role,omitempty"`
}

type WaitClient

type WaitClient interface {
	WaitReadyWithProgress(ctx context.Context, namespace, pod string, timeout time.Duration, onProgress func(kube.PodReadinessProgress)) error
	ListPods(ctx context.Context, namespace string, allNamespaces bool, labelSelector string) ([]kube.PodSummary, error)
}

Jump to

Keyboard shortcuts

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