Skip to content

Commit

Permalink
vrg: refactor findS3StoreAccessor method signature and simplify s3 st…
Browse files Browse the repository at this point in the history
…ore retrival

- Updated the `findS3StoreAccessor` method to accept `s3ProfileName` directly
- Removed unnecessary intermediate variable `localS3StoreAccessor`

Co-Authored-by: Annaraya Narasagond <[email protected]>
Signed-off-by: Raghavendra Talur <[email protected]>
  • Loading branch information
raghavendra-talur and asn1809 committed Dec 11, 2024
1 parent d5e22c7 commit 395bd2a
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions internal/controller/vrg_kubeobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,15 +534,15 @@ func (v *VRGInstance) kubeObjectsRecover(result *ctrl.Result, s3ProfileName stri
return v.kubeObjectsRecoveryStartOrResume(result, s3ProfileName, captureToRecoverFromIdentifier, log)
}

func (v *VRGInstance) findS3StoreAccessor(s3StoreProfile ramen.S3StoreProfile) (s3StoreAccessor, error) {
func (v *VRGInstance) findS3StoreAccessor(s3ProfileName string) (s3StoreAccessor, error) {
for _, s3StoreAccessor := range v.s3StoreAccessors {
if s3StoreAccessor.S3StoreProfile.S3ProfileName == s3StoreProfile.S3ProfileName {
if s3StoreAccessor.S3StoreProfile.S3ProfileName == s3ProfileName {
return s3StoreAccessor, nil
}
}

return s3StoreAccessor{},
fmt.Errorf("s3StoreProfile (%s) not found in s3StoreAccessor list", s3StoreProfile.S3ProfileName)
fmt.Errorf("s3StoreProfile (%s) not found in s3StoreAccessor list", s3ProfileName)
}

func (v *VRGInstance) getRecoverOrProtectRequest(
Expand Down Expand Up @@ -646,19 +646,11 @@ func (v *VRGInstance) kubeObjectsRecoveryStartOrResume(
groups := v.recipeElements.RecoverWorkflow
requests := make([]kubeobjects.Request, len(groups))

objectStorer, s3StoreProfile, err := v.reconciler.ObjStoreGetter.ObjectStore(
v.ctx, v.reconciler.APIReader, s3ProfileName, v.namespacedName, v.log)
if err != nil {
return fmt.Errorf("kube objects recovery object store inaccessible for profile %v: %v", s3ProfileName, err)
}

localS3StoreAccessor, err := v.findS3StoreAccessor(s3StoreProfile)
s3StoreAccessor, err := v.findS3StoreAccessor(s3ProfileName)
if err != nil {
return fmt.Errorf("kube objects recovery couldn't build s3StoreAccessor: %v", err)
}

s3StoreAccessor := s3StoreAccessor{objectStorer, localS3StoreAccessor.S3StoreProfile}

for groupNumber, recoverGroup := range groups {
rg := recoverGroup
log1 := log.WithValues("group", groupNumber, "name", rg.BackupName)
Expand Down

0 comments on commit 395bd2a

Please sign in to comment.