Documentation ¶
Index ¶
- Constants
- func GetNodeName(bd *v1alpha1.BlockDevice) string
- func NewCleanupJob(bd *v1alpha1.BlockDevice, volMode VolumeMode, tolerations []v1.Toleration, ...) (*batchv1.Job, error)
- func NewJobController(client client.Client, namespace string) *jobController
- type Cleaner
- type CleanupState
- type CleanupStatusTracker
- type JobController
- type VolumeMode
Constants ¶
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" )
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" )
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" // BlockCleanerCommand is the command used to clean raw block BlockCleanerCommand = "wipefs" )
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 ¶
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
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