// Run performs cleanup of orphaned pvcs in a Mysql cluster
Run performs cleanup of orphaned pvcs in a Mysql cluster
// Run performs cleanup of orphaned pvcs in a Mysql cluster
func (p *PVCCleaner) Run(ctx context.Context) error {
	cluster := p.cluster.Unwrap()
	if cluster.DeletionTimestamp != nil {
		log.V(2).Info("being deleted, no action", "key", p.cluster)
		return nil
	}
	pvcs, err := p.getPVCs(ctx)
	if err != nil {
		return err
	}
	for _, pvc := range pvcs {
		ord, parseErr := getOrdinal(pvc.Name)
		if parseErr == nil && ord >= *cluster.Spec.Replicas && ord != 0 {
			log.Info("cleaning up PVC", "pvc", pvc.Name, "key", p.cluster)
			if err := p.deletePVC(ctx, &pvc); err != nil {
				return err
			}
		} else if parseErr != nil {
			log.Error(parseErr, "pvc deletion error", "key", p.cluster)
		}
	}
	return nil
}
func ( p * PVCCleaner ) Run ( ctx context . Context ) error { cluster := p . cluster . Unwrap ( ) if cluster . DeletionTimestamp != nil { log . V ( 2 ) . Info ( " " , " " , p . cluster ) return nil } pvcs , err := p . getPVCs ( ctx ) if err != nil { return err } for _ , pvc := range pvcs { ord , parseErr := getOrdinal ( pvc . Name ) if parseErr == nil && ord >= * cluster . Spec . Replicas && ord != 0 { log . Info ( " " , " " , pvc . Name , " " , p . cluster ) if err := p . deletePVC ( ctx , & pvc ) ; err != nil { return err } } else if parseErr != nil { log . Error ( parseErr , " " , " " , p . cluster ) } } return nil }
Run performs cleanup of orphaned pvcs in a Mysql cluster
Run performs cleanup of orphaned pvcs in a Mysql cluster
// Find any pvcs with higher ordinal than replicas and delete them