precache

package
v0.0.0-...-5a6eb71 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LcaPrecacheServiceAccount string = "lifecycle-agent-controller-manager"
	LcaPrecacheJobName        string = "lca-precache-job"
	LcaPrecacheConfigMapName  string = "lca-precache-cm"
	LcaPrecacheFinalizer             = "lca.precache.io/finalizer"
)

LCA Resources

View Source
const (
	PrecachingSpecFilepath string = "/tmp/"
	PrecachingSpecFilename string = "images.txt"
)

Image paths

View Source
const (
	EnvLcaPrecacheImage   string = "PRECACHE_WORKLOAD_IMG"
	EnvPrecacheSpecFile   string = "PRECACHE_SPEC_FILE"
	EnvMaxPullThreads     string = "MAX_PULL_THREADS"
	EnvPrecacheBestEffort string = "PRECACHE_BEST_EFFORT"
)

Environment variable names

View Source
const (
	BackoffLimit    int32 = 0 // Allow 0 automatic retry for failed pre-caching job
	DefaultMode     int32 = 420
	RunAsUser       int64 = 0 // Run as root user
	Privileged      bool  = true
	HostDirPathType       = corev1.HostPathDirectory
)

Precaching job specs

View Source
const (
	RequestResourceCPU    string = "10m"
	RequestResourceMemory string = "512Mi"
)

Resource Limits for Job

View Source
const (
	MinNicePriority int = -20
	MaxNicePriority int = 19
)

Nice priority range

View Source
const (
	IoNiceClassNone       int = 0
	IoNiceClassRealTime   int = 1
	IoNiceClassBestEffort int = 2
	IoNiceClassIdle       int = 3
)

IoNice class values

View Source
const (
	MinIoNicePriority int = 0
	MaxIoNicePriority int = 7
)

IoNice priority range

View Source
const (
	DefaultMaxConcurrentPulls int = 10
	DefaultNicePriority       int = 0
	DefaultIoNiceClass            = IoNiceClassBestEffort
	DefaultIoNicePriority     int = 4
)

Default precaching config values

View Source
const (
	Active    string = "Active"
	Failed    string = "Failed"
	Succeeded string = "Succeeded"
)

Precache status

View Source
const StatusFile = utils.IBUWorkspacePath + "/precache_status.json"

StatusFile is the filename for persisting the precaching progress tracker

Variables

View Source
var ErrFailed = fmt.Errorf("precaching failed")

Functions

This section is empty.

Types

type Config

type Config struct {
	ImageList          []string
	NumConcurrentPulls int

	// To run pre-caching job with an adjusted niceness, which affects process scheduling.
	// Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process).
	NicePriority int

	// To configure the I/O-scheduling class and priority of a process.
	IoNiceClass    int // 0: none, 1: realtime, 2: best-effort, 3: idle
	IoNicePriority int // priority (0..7) in the specified scheduling class, only for the realtime and best-effort classes

	// Allow for environment variables to be passed in
	EnvVars []corev1.EnvVar
}

Config defines the configuration options for a pre-caching job.

func NewConfig

func NewConfig(imageList []string, envVars []corev1.EnvVar, args ...any) *Config

NewConfig creates a new Config instance with the provided imageList and optional configuration parameters. It initializes the Config with default values and updates specific fields using key-value pairs in args. Supported configuration options in args:

  • "NumConcurrentPulls" (int): Number of concurrent pulls for pre-caching.
  • "NicePriority" (int): Nice priority for pre-caching.
  • "IoNiceClass" (int): I/O nice class for pre-caching.
  • "IoNicePriority" (int): I/O nice priority for pre-caching.

Example usage:

config := NewConfig(imageList, "NumConcurrentPulls", 10, "NicePriority", 5)

type PHandler

type PHandler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

PHandler handles the precaching job

func (*PHandler) Cleanup

func (h *PHandler) Cleanup(ctx context.Context) error

Cleanup deletes precaching resources

func (*PHandler) CreateJob

func (h *PHandler) CreateJob(ctx context.Context, config *Config, ibu *lcav1alpha1.ImageBasedUpgrade) error

CreateJob creates a new precache job.

func (*PHandler) QueryJobStatus

func (h *PHandler) QueryJobStatus(ctx context.Context) (*Status, error)

QueryJobStatus retrieves the status of the precache job.

type Progress

type Progress struct {
	Total          int      `json:"total"`
	Pulled         int      `json:"pulled"`
	Failed         int      `json:"failed"`
	FailedPullList []string `json:"failed_pulls"`
	// contains filtered or unexported fields
}

Progress represents the progress tracking data for the precaching job

func (*Progress) Log

func (p *Progress) Log()

func (*Progress) Persist

func (p *Progress) Persist(filename string)

func (*Progress) Update

func (p *Progress) Update(success bool, image string)

type Status

type Status struct {
	Status   string
	Message  string
	Progress Progress
}

Status represents the status and progress information for the precaching job

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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