Skip to content

Commit

Permalink
vrg: remove veleroNamespaceName parameter from a few functions
Browse files Browse the repository at this point in the history
We were passing veleroNamespaceName through many functions where it can
be obtained from the v object. Don't pass it as a parameter until the
last call.

Functions:
- `getRecoverOrProtectRequest`
- `kubeObjectsRecoveryStartOrResume`
- `executeRecoverGroup` by removing the `veleroNamespaceName` parameter.

Co-Authored-by: Annaraya Narasagond <[email protected]>
Signed-off-by: Raghavendra Talur <[email protected]>
  • Loading branch information
raghavendra-talur and asn1809 committed Dec 16, 2024
1 parent 3ba90c1 commit c1cb4e1
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions internal/controller/vrg_kubeobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func (v *VRGInstance) getRecoverOrProtectRequest(
s3StoreAccessor s3StoreAccessor, sourceVrgNamespaceName, sourceVrgName string,
captureToRecoverFromIdentifier *ramen.KubeObjectsCaptureIdentifier,
groupNumber int, recoverGroup kubeobjects.RecoverSpec,
veleroNamespaceName string, labels map[string]string, log logr.Logger,
labels map[string]string, log logr.Logger,
) (kubeobjects.Request, bool, func() (kubeobjects.Request, error), func(kubeobjects.Request)) {
vrg := v.instance
annotations := map[string]string{}
Expand All @@ -569,7 +569,7 @@ func (v *VRGInstance) getRecoverOrProtectRequest(
s3StoreAccessor.S3CompatibleEndpoint, s3StoreAccessor.S3Bucket, s3StoreAccessor.S3Region, pathName,
s3StoreAccessor.VeleroNamespaceSecretKeyRef,
s3StoreAccessor.CACertificates,
recoverGroup.Spec, veleroNamespaceName,
recoverGroup.Spec, v.veleroNamespaceName(),
captureName,
labels, annotations)
},
Expand All @@ -593,7 +593,7 @@ func (v *VRGInstance) getRecoverOrProtectRequest(
s3StoreAccessor.S3CompatibleEndpoint, s3StoreAccessor.S3Bucket, s3StoreAccessor.S3Region, pathName,
s3StoreAccessor.VeleroNamespaceSecretKeyRef,
s3StoreAccessor.CACertificates,
recoverGroup, veleroNamespaceName,
recoverGroup, v.veleroNamespaceName(),
captureName, captureRequest,
recoverName,
labels, annotations)
Expand Down Expand Up @@ -630,7 +630,6 @@ func (v *VRGInstance) kubeObjectsRecoveryStartOrResume(
captureToRecoverFromIdentifier *ramen.KubeObjectsCaptureIdentifier,
log logr.Logger,
) error {
veleroNamespaceName := v.veleroNamespaceName()
labels := util.OwnerLabels(v.instance)

captureRequests, err := v.getCaptureRequests()
Expand Down Expand Up @@ -662,7 +661,7 @@ func (v *VRGInstance) kubeObjectsRecoveryStartOrResume(
} else {
if err := v.executeRecoverGroup(result, s3StoreAccessor,
captureToRecoverFromIdentifier, captureRequests,
recoverRequests, veleroNamespaceName, labels, groupNumber, rg,
recoverRequests, labels, groupNumber, rg,
requests, log1); err != nil {
return err
}
Expand All @@ -673,13 +672,13 @@ func (v *VRGInstance) kubeObjectsRecoveryStartOrResume(
duration := time.Since(startTime.Time)
log.Info("Kube objects recovered", "groups", len(groups), "start", startTime, "duration", duration)

return v.kubeObjectsRecoverRequestsDelete(result, veleroNamespaceName, labels)
return v.kubeObjectsRecoverRequestsDelete(result, v.veleroNamespaceName(), labels)
}

func (v *VRGInstance) executeRecoverGroup(result *ctrl.Result, s3StoreAccessor s3StoreAccessor,
captureToRecoverFromIdentifier *ramen.KubeObjectsCaptureIdentifier,
captureRequests, recoverRequests map[string]kubeobjects.Request,
veleroNamespaceName string, labels map[string]string, groupNumber int,
labels map[string]string, groupNumber int,
rg kubeobjects.RecoverSpec, requests []kubeobjects.Request, log1 logr.Logger,
) error {
sourceVrgName := v.instance.Name
Expand All @@ -688,7 +687,7 @@ func (v *VRGInstance) executeRecoverGroup(result *ctrl.Result, s3StoreAccessor s
captureRequests, recoverRequests, s3StoreAccessor,
sourceVrgNamespaceName, sourceVrgName,
captureToRecoverFromIdentifier,
groupNumber, rg, veleroNamespaceName, labels, log1,
groupNumber, rg, labels, log1,
)

var err error
Expand Down

0 comments on commit c1cb4e1

Please sign in to comment.