@@ -141,25 +141,6 @@ func (r *MantleRestoreReconciler) restore(ctx context.Context, restore *mantlev1
141141 return requeueReconciliation (), nil
142142 }
143143
144- // store the pool name in the status
145- var pv corev1.PersistentVolume
146- err = json .Unmarshal ([]byte (backup .Status .PVManifest ), & pv )
147- if err != nil {
148- logger .Error (err , "failed to unmarshal PV manifest" , "backup" , backup .Name , "namespace" , backup .Namespace )
149- return ctrl.Result {}, err
150- }
151- restore .Status .Pool = pv .Spec .CSI .VolumeAttributes ["pool" ]
152- if restore .Status .Pool == "" {
153- err := fmt .Errorf ("pool not found in PV manifest" )
154- logger .Error (err , "status.pool cannot be set" , "backup" , backup .Name , "namespace" , backup .Namespace )
155- return ctrl.Result {}, err
156- }
157- err = r .client .Status ().Update (ctx , restore )
158- if err != nil {
159- logger .Error (err , "failed to update status.pool" , "status" , restore .Status )
160- return ctrl.Result {}, err
161- }
162-
163144 // create a clone image from the backup
164145 if err := r .cloneImageFromBackup (ctx , restore , & backup ); err != nil {
165146 logger .Error (err , "failed to clone image from backup" , "backup" , backup .Name , "namespace" , backup .Namespace )
@@ -213,23 +194,27 @@ func (r *MantleRestoreReconciler) cloneImageFromBackup(ctx context.Context, rest
213194 if bkImage == "" {
214195 return fmt .Errorf ("imageName not found in PV manifest" )
215196 }
197+ pool := pv .Spec .CSI .VolumeAttributes ["pool" ]
198+ if pool == "" {
199+ return fmt .Errorf ("pool not found in PV manifest" )
200+ }
216201
217- images , err := r .ceph .RBDLs (restore . Status . Pool )
202+ images , err := r .ceph .RBDLs (pool )
218203 if err != nil {
219204 return fmt .Errorf ("failed to list RBD images: %w" , err )
220205 }
221206
222207 // check if the image already exists
223208 if slices .Contains (images , r .restoringRBDImageName (restore )) {
224- info , err := r .ceph .RBDInfo (restore . Status . Pool , r .restoringRBDImageName (restore ))
209+ info , err := r .ceph .RBDInfo (pool , r .restoringRBDImageName (restore ))
225210 if err != nil {
226211 return fmt .Errorf ("failed to get RBD info: %w" , err )
227212 }
228213 if info .Parent == nil {
229214 return fmt .Errorf ("failed to get RBD info: parent field is empty" )
230215 }
231216
232- if info .Parent .Pool == restore . Status . Pool && info .Parent .Image == bkImage && info .Parent .Snapshot == backup .Name {
217+ if info .Parent .Pool == pool && info .Parent .Image == bkImage && info .Parent .Snapshot == backup .Name {
233218 logger .Info ("image already exists" , "image" , r .restoringRBDImageName (restore ))
234219 return nil
235220 } else {
@@ -245,7 +230,7 @@ func (r *MantleRestoreReconciler) cloneImageFromBackup(ctx context.Context, rest
245230 }
246231
247232 // create a clone image from the backup
248- return r .ceph .RBDClone (restore . Status . Pool , bkImage , backup .Name , r .restoringRBDImageName (restore ), features )
233+ return r .ceph .RBDClone (pool , bkImage , backup .Name , r .restoringRBDImageName (restore ), features )
249234}
250235
251236func (r * MantleRestoreReconciler ) createOrUpdateRestoringPV (ctx context.Context , restore * mantlev1.MantleRestore , backup * mantlev1.MantleBackup ) error {
0 commit comments