artifact

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 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 Artifact name to form the PVC name.
	PVCSuffix = "-workspace"

	// DefaultJobTTLSeconds is the time after Job completion (succeeded or failed)
	// before Kubernetes automatically deletes it. Allows users to view logs via kubectl
	// before cleanup; after deletion, the PVC can be released.
	DefaultJobTTLSeconds = int32(3600)
)

Variables

This section is empty.

Functions

func BuildJob

func BuildJob(artifact *modelv1alpha1.Artifact, 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 Artifact 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.Artifact, 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 an Artifact and its workspace PVC.

func CleanupStaleJobs

func CleanupStaleJobs(ctx context.Context, c client.Client, ma *modelv1alpha1.Artifact, 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

func DeletePVC(ctx context.Context, c client.Client, ma *modelv1alpha1.Artifact) error

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

func EnsureJob

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

EnsureJob finds an existing owned Job or creates a new one. selectorLabels is used for the lookup query (version-independent); metadataLabels is applied to newly created Jobs (includes version). 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.Artifact, 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 an Artifact (Jobs, PVCs). It builds on the shared labels.Standard() base.

func OCIReference

func OCIReference(artifact *modelv1alpha1.Artifact) 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 Artifact.

func SelectorLabelsForArtifact added in v0.8.1

func SelectorLabelsForArtifact(artifactName string) map[string]string

SelectorLabelsForArtifact returns the label set used for MatchingLabels queries. It excludes Version so that operator upgrades do not cause in-flight Jobs to become invisible.

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, fallbackPhase modelv1alpha1.ArtifactPhase, fallbackDigest string) ObservationResult

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

When job is nil, if fallbackPhase is Succeeded or Failed, returns a preserved terminal state (e.g. after Job TTL cleanup); otherwise returns JobNotCreated. fallbackPhase and fallbackDigest are ignored when job is non-nil.

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