@@ -15,16 +15,6 @@ import (
15
15
// of the original PVC. This function might not run through successfully in a single run but may return an `errInProgress`, signifying
16
16
// that the caller needs to retry later.
17
17
func (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
-
28
18
// Create the backupPVC with the correct size or return it if it already exists.
29
19
backup , err := r .getOrCreateBackup (ctx , pi )
30
20
if err != nil {
@@ -34,6 +24,15 @@ func (r *StatefulSetReconciler) backupPVC(ctx context.Context, pi pvcInfo) error
34
24
// We ran successfully before
35
25
return nil
36
26
}
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
+ }
37
36
q := backup .Spec .Resources .Requests [corev1 .ResourceStorage ] // Necessary because pointer receiver
38
37
if q .Cmp (original .Spec .Resources .Requests [corev1 .ResourceStorage ]) < 0 { // Returns -1 if q < size of original
39
38
// That is not the correct PVC, but some other PVC someone else created.
0 commit comments