cleaner

package
Version: v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// VolumeModeBlock defines a raw block volume mode which means the block device should
	// be treated as raw block device
	VolumeModeBlock = "BlockVolumeMode"
	// VolumeModeFileSystem defines that the blockdevice should be treated as a block
	// formatted with filesystem and is mounted
	VolumeModeFileSystem = "FileSystemVolumeMode"
)
View Source
const (
	// EnvCleanUpJobImage is the environment variable for getting the
	// job container image
	EnvCleanUpJobImage = "CLEANUP_JOB_IMAGE"
	// ServiceAccountName is the service account in which the operator pod
	// is running. The cleanup job, pod will be started with this service account
	ServiceAccountName = "SERVICE_ACCOUNT"
)
View Source
const (
	// JobContainerName is the name of the cleanup job container
	JobContainerName = "cleaner"
	// JobNamePrefix is the prefix for the cleanup job name
	JobNamePrefix = "cleanup-"
	// BDLabel is the label set on the job for identification of the BD
	BDLabel = "blockdevice"
)

Variables

This section is empty.

Functions

func GetNodeName added in v0.4.6

func GetNodeName(bd *v1alpha1.BlockDevice) string

GetNodeName gets the Node name from BlockDevice

func NewCleanupJob

func NewCleanupJob(bd *v1alpha1.BlockDevice, volMode VolumeMode, tolerations []v1.Toleration, namespace string) (*batchv1.Job, error)

NewCleanupJob creates a new cleanup job in the namespace. It returns a Job object which can be used to start the job

func NewJobController

func NewJobController(client client.Client, namespace string) *jobController

NewJobController returns a job controller struct which can be used to get the status of the running job

Types

type Cleaner

type Cleaner struct {
	Client        client.Client
	Namespace     string
	CleanupStatus *CleanupStatusTracker
}

Cleaner handles BD cleanup For filesystem/mount based block devices, it deletes the contents of the directory For raw block devices, a `wipefs` command will be issued.

func NewCleaner

func NewCleaner(client client.Client, namespace string, cleanupTracker *CleanupStatusTracker) *Cleaner

NewCleaner creates a new cleaner which can be used for cleaning BD, and checking status of the job

func (*Cleaner) Clean

func (c *Cleaner) Clean(blockDevice *v1alpha1.BlockDevice) (bool, error)

Clean will launch a job to delete data on the BD depending on the volume mode. Job will be launched only if another job is not running or a job is in unknown state

type CleanupState

type CleanupState int

CleanupState represents the current state of the cleanup job

const (
	// CleanupStateUnknown represents an unknown state of the cleanup job
	CleanupStateUnknown CleanupState = iota + 1
	// CleanupStateNotFound defines the state when a job does not exist
	CleanupStateNotFound
	// CleanupStateRunning represents a running cleanup job
	CleanupStateRunning
	// CleanupStateSucceeded represents that the cleanup job has been completed successfully
	CleanupStateSucceeded
)

type CleanupStatusTracker

type CleanupStatusTracker struct {
	JobController JobController
}

CleanupStatusTracker is used to track the cleanup state using info provided by JobController

func (*CleanupStatusTracker) CancelJob added in v0.4.2

func (c *CleanupStatusTracker) CancelJob(bdName string) error

CancelJob cancels a job without checking the status of the job.

func (*CleanupStatusTracker) InProgress

func (c *CleanupStatusTracker) InProgress(bdName string) bool

InProgress returns whether a cleanup job is currently being done for the given BD

func (*CleanupStatusTracker) RemoveStatus

func (c *CleanupStatusTracker) RemoveStatus(bdName string) (CleanupState, error)

RemoveStatus returns the Cleanupstate of a job. If job is succeeded, it will be deleted

type JobController

type JobController interface {
	IsCleaningJobRunning(bdName string) bool
	CancelJob(bdName string) error
	RemoveJob(bdName string) (CleanupState, error)
}

JobController defines the interface for the job controller.

type VolumeMode

type VolumeMode string

VolumeMode defines the volume mode of the BlockDevice. It can be either block mode or filesystem mode

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL