miganalytic

package
v0.0.0-...-25f5b1c Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MiBSuffix       = "Mi"
	MiB             = 1048576
	RequeueInterval = 10
)
View Source
const (
	// ResticPodLabelKey is the key of the label used to discover Restic pod
	ResticPodLabelKey = "name"
	// ResticPodLabelValue is the value of the label used to discover Restic pod
	ResticPodLabelValue = "node-agent"
)
View Source
const (
	InvalidPlanRef = "InvalidPlanRef"
	Postponed      = "Postponed"
)

Types

View Source
const (
	Supported    = "Supported"
	NotSupported = "NotSupported"
	NotSet       = "NotSet"
	NotFound     = "NotFound"
	KeyError     = "KeyError"
	TestFailed   = "TestFailed"
)

Reasons

View Source
const (
	True  = migapi.True
	False = migapi.False
)

Statuses

View Source
const (
	DecimalSIGiga = BaseUnit("GB")
	DecimalSIMega = BaseUnit("MB")
	BinarySIMega  = BaseUnit("M")
	BinarySIGiga  = BaseUnit("G")
)

Supported base units used for df command

View Source
const (
	Critical = migapi.Critical
)

Categories

View Source
const DEFAULT_PV_USAGE_THRESHOLD = 3
View Source
const VolumePath = "%s/%s/volumes/*/%s"

VolumePath defines format of expected path of the volume present on Pod

Variables

View Source
var (
	Settings = &settings.Settings
)

Functions

func Add

func Add(mgr manager.Manager) error

Add creates a new MigAnalytic Controller and adds it to the Manager with default RBAC. The Manager will set fields on the Controller and Start it when the Manager is Started.

func GetRegistryInfo

func GetRegistryInfo(major, minor int, client compat.Client) (string, error)

Types

type AnalyticPredicate

type AnalyticPredicate struct {
	predicate.Funcs
	Namespace string
}

func (AnalyticPredicate) Create

func (AnalyticPredicate) Delete

func (AnalyticPredicate) Update

type BaseUnit

type BaseUnit string

BaseUnit defines supported sizes for df command

type DF

type DF struct {
	StorageCommand
}

DF represent a df command

func (*DF) GetOutputForPV

func (d *DF) GetOutputForPV(volName string, podUID types.UID) (dfOutput DFOutput)

GetOutputForPV given a volume name and pod uid, returns structured df ouput for the volume only works on outputs of commands created by DFCommand.PrepareDFCommand()

func (*DF) PrepareCommand

func (d *DF) PrepareCommand(pvcs []MigAnalyticPersistentVolumeDetails) []string

PrepareCommand given a list of volumes, creates a bulk df command for all volumes

type DFCommandExecutor

type DFCommandExecutor interface {
	Execute(map[string][]MigAnalyticPersistentVolumeDetails) ([]DFOutput, []DUOutput, error)
}

DFCommandExecutor defines an executor responsible for running DF

type DFOutput

type DFOutput struct {
	Node      string
	Name      string
	Namespace string
	StorageCommandOutput
}

DFOutput defines structured output of df per PV

type DU

type DU struct {
	StorageCommand
}

func (*DU) GetOutputForPV

func (d *DU) GetOutputForPV(volName string, podUID types.UID) (duOutput DUOutput)

GetOutputForPV given a volume name and pod uid, returns structured df ouput for the volume only works on outputs of commands created by DFCommand.PrepareDFCommand()

func (*DU) PrepareCommand

func (d *DU) PrepareCommand(pvcs []MigAnalyticPersistentVolumeDetails) []string

PrepareCommand given a list of volumes, creates a bulk df command for all volumes

type DUOutput

type DUOutput struct {
	Name      string
	Namespace string
	StorageCommandOutput
}

type DfDu

type DfDu struct {
	DF
	DU
}

type MigAnalyticPersistentVolumeDetails

type MigAnalyticPersistentVolumeDetails struct {
	Name                string
	RequestedCapacity   resource.Quantity
	PodUID              types.UID
	ProvisionedCapacity resource.Quantity
	StorageClass        *string
	Namespace           string
	VolumeName          string
}

MigAnalyticPersistentVolumeDetails defines extended properties of a volume discovered by MigAnalytic

type PersistentVolumeAdjuster

type PersistentVolumeAdjuster struct {
	Owner          *migapi.MigAnalytic
	Client         client.Client
	DFExecutor     DFCommandExecutor
	StatusRefCache map[string]*migapi.MigAnalyticNamespace
}

PersistentVolumeAdjuster defines volume adjustment context

func (*PersistentVolumeAdjuster) Run

Run runs executor, uses df output to calculate adjusted volume sizes, updates owner.status with results

type ReconcileMigAnalytic

type ReconcileMigAnalytic struct {
	client.Client
	record.EventRecorder
	// contains filtered or unexported fields
}

ReconcileMigAnalytic reconciles a MigAnalytic object

func (*ReconcileMigAnalytic) Reconcile

type ResticDFCommandExecutor

type ResticDFCommandExecutor struct {
	// Namespace is the ns in which Restic pods are present
	Namespace string
	// Client to interact with Restic pods
	Client compat.Client
	// ResticPodReferences is a local cache of known Restic pods
	ResticPodReferences map[string]*corev1.Pod
}

ResticDFCommandExecutor uses Restic pods to run DF command

func (*ResticDFCommandExecutor) Execute

Execute given a map node->[]pvc, runs Df command for each, returns list of structured df output per pvc

func (*ResticDFCommandExecutor) ExecuteStorageCommands

func (r *ResticDFCommandExecutor) ExecuteStorageCommands(podRef *corev1.Pod, persistentVolumes []MigAnalyticPersistentVolumeDetails) (DF, DU)

ExecuteStorageCommands given a podRef and a list of volumes, runs df command, returns with structured command context any errors running the df command are suppressed here. DFCommand.stdErr field should be used to determine failure

type StorageCommand

type StorageCommand struct {
	// stdout from df
	StdOut string
	// stderr from df
	StdErr string
	// Base unit used for df
	BlockSize BaseUnit
	// BaseLocation defines path where volumes can be found
	BaseLocation string
}

type StorageCommandOutput

type StorageCommandOutput struct {
	UsagePercentage int64
	Usage           int64
	TotalSize       resource.Quantity
	IsError         bool
}

Jump to

Keyboard shortcuts

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