precache

package
v0.0.0-...-d416164 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LcaPrecacheServiceAccount string = "lifecycle-agent-controller-manager"
	LcaPrecacheResourceName   string = "lca-prep-precache"
	LcaPrecacheFinalizer             = "lca.openshift.io/precache-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"
	ImageListFile                = "var/tmp/imageListFile"
)

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 StatusFile = utils.IBUWorkspacePath + "/precache_status.json"

StatusFile is the filename for persisting the precaching progress tracker

Variables

This section is empty.

Functions

func GetJob

func GetJob(ctx context.Context, c client.Client) (*batchv1.Job, error)

func GetPrecacheStatusFileContent

func GetPrecacheStatusFileContent() string

GetPrecacheStatusFileContent try to read the content for additional in progress status msg

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) CreateJobAndConfigMap

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

CreateJobAndConfigMap creates a new 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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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