@@ -81,32 +81,14 @@ func (r *VolumeReconciler) iriVolumeAnnotations(_ *storagev1alpha1.Volume) map[s
81
81
return map [string ]string {}
82
82
}
83
83
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 ) {
85
85
res , err := r .VolumeRuntime .ListVolumes (ctx , & iri.ListVolumesRequest {
86
86
Filter : & iri.VolumeFilter {
87
- LabelSelector : map [string ]string {
88
- volumepoolletv1alpha1 .VolumeNamespaceLabel : volumeKey .Namespace ,
89
- volumepoolletv1alpha1 .VolumeNameLabel : volumeKey .Name ,
90
- },
87
+ Id : string (volumeID ),
91
88
},
92
89
})
93
90
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 )
110
92
}
111
93
return res .Volumes , nil
112
94
}
@@ -124,18 +106,18 @@ func (r *VolumeReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr
124
106
if ! apierrors .IsNotFound (err ) {
125
107
return ctrl.Result {}, fmt .Errorf ("error getting volume %s: %w" , req .NamespacedName , err )
126
108
}
127
- return r .deleteGone (ctx , log , req . NamespacedName )
109
+ return r .deleteGone (ctx , log , volume . UID )
128
110
}
129
111
return r .reconcileExists (ctx , log , volume )
130
112
}
131
113
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 ) {
133
115
log .V (1 ).Info ("Delete gone" )
134
116
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 )
137
119
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 )
139
121
}
140
122
141
123
ok , err := r .deleteIRIVolumes (ctx , log , volumes )
@@ -206,7 +188,7 @@ func (r *VolumeReconciler) delete(ctx context.Context, log logr.Logger, volume *
206
188
log .V (1 ).Info ("Finalizer present" )
207
189
208
190
log .V (1 ).Info ("Listing volumes" )
209
- volumes , err := r .listIRIVolumesByUID (ctx , volume .UID )
191
+ volumes , err := r .getIRIVolumeByID (ctx , volume .UID )
210
192
if err != nil {
211
193
return ctrl.Result {}, fmt .Errorf ("error listing volumes by uid: %w" , err )
212
194
}
@@ -245,6 +227,7 @@ func (r *VolumeReconciler) prepareIRIVolumeMetadata(volume *storagev1alpha1.Volu
245
227
errs = append (errs , fmt .Errorf ("error preparing iri volume labels: %w" , err ))
246
228
}
247
229
return & irimeta.ObjectMetadata {
230
+ Id : string (volume .UID ),
248
231
Labels : labels ,
249
232
Annotations : r .iriVolumeAnnotations (volume ),
250
233
}, errs
@@ -375,9 +358,7 @@ func (r *VolumeReconciler) reconcile(ctx context.Context, log logr.Logger, volum
375
358
log .V (1 ).Info ("Listing volumes" )
376
359
res , err := r .VolumeRuntime .ListVolumes (ctx , & iri.ListVolumesRequest {
377
360
Filter : & iri.VolumeFilter {
378
- LabelSelector : map [string ]string {
379
- volumepoolletv1alpha1 .VolumeUIDLabel : string (volume .UID ),
380
- },
361
+ Id : string (volume .UID ),
381
362
},
382
363
})
383
364
if err != nil {
@@ -415,7 +396,7 @@ func (r *VolumeReconciler) create(ctx context.Context, log logr.Logger, volume *
415
396
return ctrl.Result {}, nil
416
397
}
417
398
418
- log .V (1 ).Info ("Creating volume" )
399
+ log .V (1 ).Info ("Creating volume" , "volume before " , iriVolume )
419
400
res , err := r .VolumeRuntime .CreateVolume (ctx , & iri.CreateVolumeRequest {
420
401
Volume : iriVolume ,
421
402
})
@@ -427,14 +408,14 @@ func (r *VolumeReconciler) create(ctx context.Context, log logr.Logger, volume *
427
408
428
409
volumeID := iriVolume .Metadata .Id
429
410
log = log .WithValues ("VolumeID" , volumeID )
430
- log .V (1 ).Info ("Created" )
411
+ log .V (1 ).Info ("Created" , "volume after " , iriVolume )
431
412
432
413
log .V (1 ).Info ("Updating status" )
433
414
if err := r .updateStatus (ctx , log , volume , iriVolume ); err != nil {
434
415
return ctrl.Result {}, fmt .Errorf ("error updating volume status: %w" , err )
435
416
}
436
417
437
- log .V (1 ).Info ("Created" )
418
+ log .V (1 ).Info ("Created" , "volume after " , iriVolume )
438
419
return ctrl.Result {}, nil
439
420
}
440
421
0 commit comments