@@ -85,7 +85,9 @@ func (cvg *commonVolumeGroup) generateVolumeGroup(csiID util.CSIIdentifier) erro
8585 cvg .namespace = namespace
8686 cvg .pool = pool
8787
88- return nil
88+ _ , err = cvg .Exists (context .Background ())
89+
90+ return err
8991}
9092
9193// generateVolumeGroupFromMapping checks the clusterID and poolID mapping and
@@ -229,7 +231,7 @@ func (cvg *commonVolumeGroup) getVolumeGroupAttributes(ctx context.Context) (*jo
229231 if attrs .GroupName == "" {
230232 log .ErrorLog (ctx , "volume group with id %v not found" , cvg .id )
231233
232- return nil , ErrRBDGroupNotFound
234+ return nil , util . ErrRBDGroupNotFound
233235 }
234236
235237 cvg .requestName = attrs .RequestName
@@ -356,12 +358,12 @@ func (cvg *commonVolumeGroup) GetIOContext(ctx context.Context) (*rados.IOContex
356358
357359 conn , err := cvg .getConnection (ctx )
358360 if err != nil {
359- return nil , fmt .Errorf ("%w: failed to connect: %w" , ErrRBDGroupNotConnected , err )
361+ return nil , fmt .Errorf ("%w: failed to connect: %w" , util . ErrRBDGroupNotConnected , err )
360362 }
361363
362364 ioctx , err := conn .GetIoctx (cvg .pool )
363365 if err != nil {
364- return nil , fmt .Errorf ("%w: failed to get IOContext: %w" , ErrRBDGroupNotConnected , err )
366+ return nil , fmt .Errorf ("%w: failed to get IOContext: %w" , util . ErrRBDGroupNotConnected , err )
365367 }
366368
367369 if cvg .namespace != "" {
@@ -417,3 +419,13 @@ func (cvg *commonVolumeGroup) GetCreationTime(ctx context.Context) (*time.Time,
417419
418420 return cvg .creationTime , nil
419421}
422+
423+ // Exists checks if the volume group exists in the journal.
424+ func (cvg * commonVolumeGroup ) Exists (ctx context.Context ) (bool , error ) {
425+ _ , err := cvg .getVolumeGroupAttributes (context .Background ())
426+ if err != nil {
427+ return false , err
428+ }
429+
430+ return true , nil
431+ }
0 commit comments