func (ls *LocalStorage) inspectPVs() (int, error) {
	log := ls.deps.Log
	list, err := ls.deps.KubeCli.CoreV1().PersistentVolumes().List(context.Background(), metav1.ListOptions{})
	if err != nil {
		return 0, errors.WithStack(err)
	}
	spec := ls.apiObject.Spec
	availableVolumes := 0
	cleanupBeforeTimestamp := time.Now().Add(time.Hour * -24)
	for _, pv := range list.Items {
		if pv.Spec.StorageClassName != spec.StorageClass.Name {
			continue
		}
		switch pv.Status.Phase {
		case v1.VolumeAvailable:
			if pv.GetObjectMeta().GetCreationTimestamp().Time.Before(cleanupBeforeTimestamp) {
				if ls.isOwnerOf(&pv) {
					log.Debug().Str("name", pv.GetName()).Msg("Added PersistentVolume to cleaner")
					ls.pvCleaner.Add(pv)
				} else {
					log.Debug().Str("name", pv.GetName()).Msg("PersistentVolume is not owned by us")
					availableVolumes++
				}
			} else {
				availableVolumes++
			}
		case v1.VolumeReleased:
			if ls.isOwnerOf(&pv) {
				log.Debug().Str("name", pv.GetName()).Msg("Added PersistentVolume to cleaner")
				ls.pvCleaner.Add(pv)
			} else {
				log.Debug().Str("name", pv.GetName()).Msg("PersistentVolume is not owned by us")
			}
		}
	}
	return availableVolumes, nil
}
inspectPVs queries all PersistentVolume's and triggers a cleanup for
released volumes.
Returns the number of available PV's.
package storage
import (
	"context"
	"time"
	"github.com/arangodb/kube-arangodb/pkg/util/errors"
	v1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)