Documentation ¶
Index ¶
- Constants
- func NewCleanupJob(pv *apiv1.PersistentVolume, volMode apiv1.PersistentVolumeMode, ...) (*batch_v1.Job, error)
- type CleanupState
- type CleanupStatusTracker
- type Deleter
- type FakeJobController
- func (c *FakeJobController) IsCleaningJobRunning(pvName string) bool
- func (c *FakeJobController) MarkRunning(pvName string)
- func (c *FakeJobController) MarkSucceeded(pvName string)
- func (c *FakeJobController) RemoveJob(pvName string) (CleanupState, *time.Time, error)
- func (c *FakeJobController) Run(stopCh <-chan struct{})
- type FakeProcTableImpl
- func (f *FakeProcTableImpl) IsEmpty() bool
- func (f *FakeProcTableImpl) IsRunning(pvName string) bool
- func (f *FakeProcTableImpl) MarkFailed(pvName string) error
- func (f *FakeProcTableImpl) MarkRunning(pvName string) error
- func (f *FakeProcTableImpl) MarkSucceeded(pvName string) error
- func (f *FakeProcTableImpl) RemoveEntry(pvName string) (CleanupState, *time.Time, error)
- func (f *FakeProcTableImpl) Stats() ProcTableStats
- type JobController
- type ProcEntry
- type ProcTable
- type ProcTableImpl
- func (v *ProcTableImpl) IsEmpty() bool
- func (v *ProcTableImpl) IsRunning(pvName string) bool
- func (v *ProcTableImpl) MarkFailed(pvName string) error
- func (v *ProcTableImpl) MarkRunning(pvName string) error
- func (v *ProcTableImpl) MarkSucceeded(pvName string) error
- func (v *ProcTableImpl) RemoveEntry(pvName string) (CleanupState, *time.Time, error)
- func (v *ProcTableImpl) Stats() ProcTableStats
- type ProcTableStats
Constants ¶
const ( // JobContainerName is name of the container running the cleanup process. JobContainerName = "cleaner" // JobNamePrefix is the prefix of the name of the cleaning job. JobNamePrefix = "cleanup-" // PVLabel is the label name whose value is the pv name. PVLabel = "pv" // PVUuidLabel is the label name whose value is the pv uuid. PVUuidLabel = "pvuuid" // DeviceAnnotation is the annotation that specifies the device path. DeviceAnnotation = "device" // StartTimeAnnotation is the annotation that specifies the job start time. // This is the time when we begin to submit job to apiserver. We use this // instead of job or pod start time to include k8s pod start latency into // volume deletion time. // Time is formatted in time.RFC3339Nano. StartTimeAnnotation = "start-time" )
Variables ¶
This section is empty.
Functions ¶
func NewCleanupJob ¶
func NewCleanupJob(pv *apiv1.PersistentVolume, volMode apiv1.PersistentVolumeMode, imageName string, nodeName string, namespace string, mountPath string, config common.MountConfig) (*batch_v1.Job, error)
NewCleanupJob creates manifest for a cleaning job.
Types ¶
type CleanupState ¶
type CleanupState int
CleanupState indicates the state of the cleanup process.
const ( // CSUnknown State of the cleanup is unknown. CSUnknown CleanupState = iota + 1 // CSNotFound No cleanup process was found. CSNotFound // CSRunning Cleanup process is still running. CSRunning // CSFailed Cleanup process has ended in failure. CSFailed // CSSucceeded Cleanup process has ended successfully. CSSucceeded )
type CleanupStatusTracker ¶
type CleanupStatusTracker struct { ProcTable ProcTable JobController JobController }
CleanupStatusTracker tracks cleanup processes that are either process based or jobs based.
func (*CleanupStatusTracker) InProgress ¶
func (c *CleanupStatusTracker) InProgress(pvName string, isJob bool) bool
InProgress returns true if the cleaning for the specified PV is in progress.
func (*CleanupStatusTracker) RemoveStatus ¶
func (c *CleanupStatusTracker) RemoveStatus(pvName string, isJob bool) (CleanupState, *time.Time, error)
RemoveStatus removes and returns the status and start time of a completed cleaning process. The method returns an error if the process has not yet completed.
type Deleter ¶
type Deleter struct { *common.RuntimeConfig CleanupStatus *CleanupStatusTracker }
Deleter handles PV cleanup and object deletion For file-based volumes, it deletes the contents of the directory
func NewDeleter ¶
func NewDeleter(config *common.RuntimeConfig, cleanupTracker *CleanupStatusTracker) *Deleter
NewDeleter creates a Deleter object to handle the cleanup and deletion of local PVs allocated by this provisioner
type FakeJobController ¶
type FakeJobController struct { // IsRunningCount keeps count of number of times IsRunning() was called IsRunningCount int RemoveCompletedCount int // contains filtered or unexported fields }
FakeJobController for mocking.
func NewFakeJobController ¶
func NewFakeJobController() *FakeJobController
NewFakeJobController instantiates mock job controller.
func (*FakeJobController) IsCleaningJobRunning ¶
func (c *FakeJobController) IsCleaningJobRunning(pvName string) bool
IsCleaningJobRunning mocks the interface method.
func (*FakeJobController) MarkRunning ¶
func (c *FakeJobController) MarkRunning(pvName string)
MarkRunning simulates a job running for specified PV.
func (*FakeJobController) MarkSucceeded ¶
func (c *FakeJobController) MarkSucceeded(pvName string)
MarkSucceeded simulates a job running for specified PV.
func (*FakeJobController) RemoveJob ¶
func (c *FakeJobController) RemoveJob(pvName string) (CleanupState, *time.Time, error)
RemoveJob mocks the interface method.
func (*FakeJobController) Run ¶
func (c *FakeJobController) Run(stopCh <-chan struct{})
Run mocks the interface method.
type FakeProcTableImpl ¶
type FakeProcTableImpl struct { // IsRunningCount keeps count of number of times IsRunning() was called IsRunningCount int // MarkRunningCount keeps count of number of times MarkRunning() was called MarkRunningCount int // MarkDoneCount keeps count of number of times MarkDone() was called MarkDoneCount int // RemoveCount keeps count of number of times Remove() was called RemoveCount int // StatsCount keeps count of number of times Stats() was called StatsCount int // contains filtered or unexported fields }
FakeProcTableImpl creates a mock proc table that enables testing.
func NewFakeProcTable ¶
func NewFakeProcTable() *FakeProcTableImpl
NewFakeProcTable returns a BlockCleaner
func (*FakeProcTableImpl) IsEmpty ¶
func (f *FakeProcTableImpl) IsEmpty() bool
IsEmpty Check if any cleanup process is running
func (*FakeProcTableImpl) IsRunning ¶
func (f *FakeProcTableImpl) IsRunning(pvName string) bool
IsRunning Check if cleanup process is still running
func (*FakeProcTableImpl) MarkFailed ¶
func (f *FakeProcTableImpl) MarkFailed(pvName string) error
MarkFailed Indicate the process has failed.
func (*FakeProcTableImpl) MarkRunning ¶
func (f *FakeProcTableImpl) MarkRunning(pvName string) error
MarkRunning Indicate that process is running.
func (*FakeProcTableImpl) MarkSucceeded ¶
func (f *FakeProcTableImpl) MarkSucceeded(pvName string) error
MarkSucceeded Indicate the process has succeeded.
func (*FakeProcTableImpl) RemoveEntry ¶
func (f *FakeProcTableImpl) RemoveEntry(pvName string) (CleanupState, *time.Time, error)
RemoveEntry removes the entry from the proc table.
func (*FakeProcTableImpl) Stats ¶
func (f *FakeProcTableImpl) Stats() ProcTableStats
Stats returns stats of ProcTable.
type JobController ¶
type JobController interface { Run(stopCh <-chan struct{}) IsCleaningJobRunning(pvName string) bool RemoveJob(pvName string) (CleanupState, *time.Time, error) }
JobController defines the interface for the job controller.
func NewJobController ¶
func NewJobController(labelmap map[string]string, config *common.RuntimeConfig) (JobController, error)
NewJobController instantiates a new job controller.
type ProcEntry ¶
type ProcEntry struct { StartTime time.Time Status CleanupState }
ProcEntry represents an entry in the proc table
type ProcTable ¶
type ProcTable interface { // CleanupBlockPV deletes block based PV IsRunning(pvName string) bool IsEmpty() bool MarkRunning(pvName string) error MarkFailed(pvName string) error MarkSucceeded(pvName string) error RemoveEntry(pvName string) (CleanupState, *time.Time, error) Stats() ProcTableStats }
ProcTable Interface for tracking running processes
type ProcTableImpl ¶
type ProcTableImpl struct {
// contains filtered or unexported fields
}
ProcTableImpl Implementation of BLockCleaner interface
func (*ProcTableImpl) IsEmpty ¶
func (v *ProcTableImpl) IsEmpty() bool
IsEmpty Check if any cleanup process is running
func (*ProcTableImpl) IsRunning ¶
func (v *ProcTableImpl) IsRunning(pvName string) bool
IsRunning Check if cleanup process is still running
func (*ProcTableImpl) MarkFailed ¶
func (v *ProcTableImpl) MarkFailed(pvName string) error
MarkFailed Indicate the process has failed in its run.
func (*ProcTableImpl) MarkRunning ¶
func (v *ProcTableImpl) MarkRunning(pvName string) error
MarkRunning Indicate that process is running.
func (*ProcTableImpl) MarkSucceeded ¶
func (v *ProcTableImpl) MarkSucceeded(pvName string) error
MarkSucceeded Indicate the process has succeeded in its run.
func (*ProcTableImpl) RemoveEntry ¶
func (v *ProcTableImpl) RemoveEntry(pvName string) (CleanupState, *time.Time, error)
RemoveEntry Removes proctable entry and returns final state and start time of cleanup. Must only be called and cleanup that has ended, else error is returned.
func (*ProcTableImpl) Stats ¶
func (v *ProcTableImpl) Stats() ProcTableStats
Stats returns stats of ProcTable.
type ProcTableStats ¶
ProcTableStats represents stats of ProcTable.