@@ -15,16 +15,6 @@ import (
1515// of the original PVC. This function might not run through successfully in a single run but may return an `errInProgress`, signifying
1616// that the caller needs to retry later.
1717func (r * StatefulSetReconciler ) backupPVC (ctx context.Context , pi pvcInfo ) error {
18- // Check if the original PVC still exists. If not there is a problem.
19- original := corev1.PersistentVolumeClaim {}
20- if err := r .Get (ctx , client.ObjectKey {Name : pi .Name , Namespace : pi .Namespace }, & original ); err != nil {
21- if apierrors .IsNotFound (err ) {
22- // If its not present we are in an inconsitent state
23- return newErrCritical ("original pvc missing while trying to back it up" )
24- }
25- return err
26- }
27-
2818 // Create the backupPVC with the correct size or return it if it already exists.
2919 backup , err := r .getOrCreateBackup (ctx , pi )
3020 if err != nil {
@@ -34,6 +24,15 @@ func (r *StatefulSetReconciler) backupPVC(ctx context.Context, pi pvcInfo) error
3424 // We ran successfully before
3525 return nil
3626 }
27+ // Check if the original PVC still exists. If not there is a problem.
28+ original := corev1.PersistentVolumeClaim {}
29+ if err := r .Get (ctx , client.ObjectKey {Name : pi .Name , Namespace : pi .Namespace }, & original ); err != nil {
30+ if apierrors .IsNotFound (err ) {
31+ // If its not present we are in an inconsitent state
32+ return newErrCritical ("original pvc missing while trying to back it up" )
33+ }
34+ return err
35+ }
3736 q := backup .Spec .Resources .Requests [corev1 .ResourceStorage ] // Necessary because pointer receiver
3837 if q .Cmp (original .Spec .Resources .Requests [corev1 .ResourceStorage ]) < 0 { // Returns -1 if q < size of original
3938 // That is not the correct PVC, but some other PVC someone else created.
0 commit comments