Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto remove the pv with hardware problems #126

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion pkg/deleter/deleter.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,30 @@ func NewDeleter(config *common.RuntimeConfig, cleanupTracker *CleanupStatusTrack
// delete them
func (d *Deleter) DeletePVs() {
for _, pv := range d.Cache.ListPVs() {
if pv.Status.Phase != v1.VolumeReleased {

var shouldTryToDelete bool
switch pv.Status.Phase {
// PV which is Released state, provisioner will clear it's data
case v1.VolumeReleased:
shouldTryToDelete = true
// When the pv has a hardware problem,
// 1. If the pv is Bound state, some pod is using it, after migrating
// the affected pod to another node, we can delete pvc, so pv will be
// Released state, similar to above.
// 2. If the pv is Available state, after recycling the hardware,
// provisioner automatically removes the pv both in cluster and
// its cache.
case v1.VolumeAvailable:
_, err := os.Stat(pv.Spec.Local.Path)
if os.IsNotExist(err) {
shouldTryToDelete = true
}
}

if !shouldTryToDelete {
continue
}

name := pv.Name
switch pv.Spec.PersistentVolumeReclaimPolicy {
case v1.PersistentVolumeReclaimRetain:
Expand Down