artifact

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// ConditionTypeReady indicates whether the artifact pipeline has completed
	// and the OCI artifact is available in the target registry.
	ConditionTypeReady = "Ready"

	// ComponentArtifact is the Kubernetes recommended label component value.
	ComponentArtifact = "model-artifact"

	// WorkspaceVolumeName is the name of the PVC volume mounted into the Job Pod.
	WorkspaceVolumeName = "workspace"

	// WorkspaceMountPath is the mount path for the workspace volume inside the Job Pod.
	WorkspaceMountPath = "/workspace"

	// PVCSuffix is appended to the ModelArtifact name to form the PVC name.
	PVCSuffix = "-workspace"
)

Variables

This section is empty.

Functions

func BuildJob

func BuildJob(artifact *modelv1alpha1.ModelArtifact, kitImage string, labels map[string]string) *batchv1.Job

BuildJob constructs a batch/v1 Job that executes the kit import → pack → push pipeline.

Design choices:

  • GenerateName avoids name collisions when the ModelArtifact spec changes
  • backoffLimit=0 prevents the Job from retrying on its own; the controller handles retries
  • terminationMessagePath writes the OCI digest for the controller to read
  • Secrets are injected via env valueFrom, never passing through the controller

func BuildPVC

func BuildPVC(artifact *modelv1alpha1.ModelArtifact, labels map[string]string) *corev1.PersistentVolumeClaim

BuildPVC constructs a PersistentVolumeClaim for the import/pack/push workspace. The PVC name is deterministic (<artifact-name>-workspace) since there is a 1:1 relationship between a ModelArtifact and its workspace PVC.

func CleanupStaleJobs

func CleanupStaleJobs(ctx context.Context, c client.Client, ma *modelv1alpha1.ModelArtifact, labels map[string]string) error

CleanupStaleJobs deletes all owned Jobs that are not yet marked for deletion. Called when generation changes to remove Jobs from the previous generation.

func DeletePVC

DeletePVC removes the workspace PVC. Non-existence is ignored.

func EnsureJob

func EnsureJob(ctx context.Context, c client.Client, scheme *runtime.Scheme, ma *modelv1alpha1.ModelArtifact, kitImage string, labels map[string]string) (*batchv1.Job, bool, error)

EnsureJob finds an existing owned Job or creates a new one. Returns the job (existing or newly created), whether it was created, and any error.

func EnsurePVC

func EnsurePVC(ctx context.Context, c client.Client, scheme *runtime.Scheme, ma *modelv1alpha1.ModelArtifact, labels map[string]string) error

EnsurePVC creates the workspace PVC if it does not exist. Caller must pass a client and scheme for OwnerReference.

func FindOwnedJob

func FindOwnedJob(ctx context.Context, c client.Client, namespace string, labels map[string]string, owner metav1.Object) (*batchv1.Job, error)

FindOwnedJob returns the first non-deleted Job owned by owner with given labels.

func LabelsForArtifact

func LabelsForArtifact(artifactName, version string) map[string]string

LabelsForArtifact returns the standard set of labels for resources managed by a ModelArtifact (Jobs, PVCs). It builds on the shared labels.Standard() base.

func OCIReference

func OCIReference(artifact *modelv1alpha1.ModelArtifact) string

OCIReference returns the full OCI target reference for kit pack/push.

func PVCName

func PVCName(artifactName string) string

PVCName returns the deterministic PVC name for a given ModelArtifact.

Types

type ObservationResult

type ObservationResult struct {
	Phase   modelv1alpha1.ArtifactPhase
	Ready   metav1.ConditionStatus
	Reason  string
	Message string
	Digest  string
}

ObservationResult encapsulates the observed state derived from a Job and its Pods.

func ObserveJobStatus

func ObserveJobStatus(job *batchv1.Job, pods []corev1.Pod) ObservationResult

ObserveJobStatus derives the ModelArtifact phase, condition, and digest from the current state of a Job and its owned Pods.

This is a pure function with no side effects — all observation logic is testable without a running cluster.

Jump to

Keyboard shortcuts

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