@@ -81,32 +81,14 @@ func (r *VolumeReconciler) iriVolumeAnnotations(_ *storagev1alpha1.Volume) map[s
8181 return map [string ]string {}
8282}
8383
84- func (r * VolumeReconciler ) listIRIVolumesByKey (ctx context.Context , volumeKey client. ObjectKey ) ([]* iri.Volume , error ) {
84+ func (r * VolumeReconciler ) getIRIVolumeByID (ctx context.Context , volumeID types. UID ) ([]* iri.Volume , error ) {
8585 res , err := r .VolumeRuntime .ListVolumes (ctx , & iri.ListVolumesRequest {
8686 Filter : & iri.VolumeFilter {
87- LabelSelector : map [string ]string {
88- volumepoolletv1alpha1 .VolumeNamespaceLabel : volumeKey .Namespace ,
89- volumepoolletv1alpha1 .VolumeNameLabel : volumeKey .Name ,
90- },
87+ Id : string (volumeID ),
9188 },
9289 })
9390 if err != nil {
94- return nil , fmt .Errorf ("error listing volumes by key: %w" , err )
95- }
96- volumes := res .Volumes
97- return volumes , nil
98- }
99-
100- func (r * VolumeReconciler ) listIRIVolumesByUID (ctx context.Context , volumeUID types.UID ) ([]* iri.Volume , error ) {
101- res , err := r .VolumeRuntime .ListVolumes (ctx , & iri.ListVolumesRequest {
102- Filter : & iri.VolumeFilter {
103- LabelSelector : map [string ]string {
104- volumepoolletv1alpha1 .VolumeUIDLabel : string (volumeUID ),
105- },
106- },
107- })
108- if err != nil {
109- return nil , fmt .Errorf ("error listing volumes by uid: %w" , err )
91+ return nil , fmt .Errorf ("error listing volumes by id: %w" , err )
11092 }
11193 return res .Volumes , nil
11294}
@@ -124,18 +106,18 @@ func (r *VolumeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
124106 if ! apierrors .IsNotFound (err ) {
125107 return ctrl.Result {}, fmt .Errorf ("error getting volume %s: %w" , req .NamespacedName , err )
126108 }
127- return r .deleteGone (ctx , log , req . NamespacedName )
109+ return r .deleteGone (ctx , log , volume . UID )
128110 }
129111 return r .reconcileExists (ctx , log , volume )
130112}
131113
132- func (r * VolumeReconciler ) deleteGone (ctx context.Context , log logr.Logger , volumeKey client. ObjectKey ) (ctrl.Result , error ) {
114+ func (r * VolumeReconciler ) deleteGone (ctx context.Context , log logr.Logger , volumeUID types. UID ) (ctrl.Result , error ) {
133115 log .V (1 ).Info ("Delete gone" )
134116
135- log .V (1 ).Info ("Listing iri volumes by key " )
136- volumes , err := r .listIRIVolumesByKey (ctx , volumeKey )
117+ log .V (1 ).Info ("Listing iri volumes by Id " )
118+ volumes , err := r .getIRIVolumeByID (ctx , volumeUID )
137119 if err != nil {
138- return ctrl.Result {}, fmt .Errorf ("error listing iri volumes by key : %w" , err )
120+ return ctrl.Result {}, fmt .Errorf ("error listing iri volumes by Id : %w" , err )
139121 }
140122
141123 ok , err := r .deleteIRIVolumes (ctx , log , volumes )
@@ -206,7 +188,7 @@ func (r *VolumeReconciler) delete(ctx context.Context, log logr.Logger, volume *
206188 log .V (1 ).Info ("Finalizer present" )
207189
208190 log .V (1 ).Info ("Listing volumes" )
209- volumes , err := r .listIRIVolumesByUID (ctx , volume .UID )
191+ volumes , err := r .getIRIVolumeByID (ctx , volume .UID )
210192 if err != nil {
211193 return ctrl.Result {}, fmt .Errorf ("error listing volumes by uid: %w" , err )
212194 }
@@ -245,6 +227,7 @@ func (r *VolumeReconciler) prepareIRIVolumeMetadata(volume *storagev1alpha1.Volu
245227 errs = append (errs , fmt .Errorf ("error preparing iri volume labels: %w" , err ))
246228 }
247229 return & irimeta.ObjectMetadata {
230+ Id : string (volume .UID ),
248231 Labels : labels ,
249232 Annotations : r .iriVolumeAnnotations (volume ),
250233 }, errs
@@ -375,9 +358,7 @@ func (r *VolumeReconciler) reconcile(ctx context.Context, log logr.Logger, volum
375358 log .V (1 ).Info ("Listing volumes" )
376359 res , err := r .VolumeRuntime .ListVolumes (ctx , & iri.ListVolumesRequest {
377360 Filter : & iri.VolumeFilter {
378- LabelSelector : map [string ]string {
379- volumepoolletv1alpha1 .VolumeUIDLabel : string (volume .UID ),
380- },
361+ Id : string (volume .UID ),
381362 },
382363 })
383364 if err != nil {
@@ -415,7 +396,7 @@ func (r *VolumeReconciler) create(ctx context.Context, log logr.Logger, volume *
415396 return ctrl.Result {}, nil
416397 }
417398
418- log .V (1 ).Info ("Creating volume" )
399+ log .V (1 ).Info ("Creating volume" , "volume before " , iriVolume )
419400 res , err := r .VolumeRuntime .CreateVolume (ctx , & iri.CreateVolumeRequest {
420401 Volume : iriVolume ,
421402 })
@@ -427,14 +408,14 @@ func (r *VolumeReconciler) create(ctx context.Context, log logr.Logger, volume *
427408
428409 volumeID := iriVolume .Metadata .Id
429410 log = log .WithValues ("VolumeID" , volumeID )
430- log .V (1 ).Info ("Created" )
411+ log .V (1 ).Info ("Created" , "volume after " , iriVolume )
431412
432413 log .V (1 ).Info ("Updating status" )
433414 if err := r .updateStatus (ctx , log , volume , iriVolume ); err != nil {
434415 return ctrl.Result {}, fmt .Errorf ("error updating volume status: %w" , err )
435416 }
436417
437- log .V (1 ).Info ("Created" )
418+ log .V (1 ).Info ("Created" , "volume after " , iriVolume )
438419 return ctrl.Result {}, nil
439420}
440421
0 commit comments