-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #1128: Removed multiple DPA get calls for Reconcilers #1316
base: master
Are you sure you want to change the base?
Conversation
7d9cd21
to
268eb03
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
/retest |
/retest |
3 similar comments
/retest |
/retest |
/retest |
@sseago @shubham-pampattiwar please review :) |
I am unsure about the changes here, I think the rationale behind fetching the DPA explicitly in every reconcile function was to get the latest DPA available in the cluster. |
But we are not updating the DPA after validation right? so we can use the same DPA fetching it once? |
Each reconcile you see is called right after the other in the same loop. Current implementation prior to this PR mean we're doing like 10 or so get calls within a span of 1-2 seconds, more likely to have issues with "outdated-copy" during update calls that rely on multiple gets so close to each other. Also the client backoff throttling. I think it's best to get once, update once in entire batch. Perhaps add to the end This would help in cu environments with busy api server. |
if err := r.Get(ctx, req.NamespacedName, &dpa); err != nil {
log.Error(err, "unable to fetch DataProtectionApplication CR")
return result, nil
}
+ //--deep copy here
// set client to pkg/client for use in non-reconcile functions
oadpClient.SetClient(r.Client)
_, err := ReconcileBatch(r.Log,
r.ValidateDataProtectionCR,
r.ReconcileFsRestoreHelperConfig,
...
)
if err != nil {
apimeta.SetStatusCondition(&dpa.Status.Conditions,
metav1.Condition{
Type: oadpv1alpha1.ConditionReconciled,
Status: metav1.ConditionFalse,
Reason: oadpv1alpha1.ReconciledReasonError,
Message: err.Error(),
},
)
} else {
apimeta.SetStatusCondition(&dpa.Status.Conditions,
metav1.Condition{
Type: oadpv1alpha1.ConditionReconciled,
Status: metav1.ConditionTrue,
Reason: oadpv1alpha1.ReconciledReasonComplete,
Message: oadpv1alpha1.ReconcileCompleteMessage,
},
)
}
+ // patch spec updates
statusErr := r.Client.Status().Update(ctx, &dpa)
if err == nil { // Don't mask previous error
err = statusErr
} |
@kaovilai why do we need a deep copy here? Do you mean to create a copy of DPA (lets say copiedDpa) and pass that copiedDpa in all the reconcile functions, and then based on that copiedDpa, update the dpa using Patch() ? |
I meant deepcopy to have orignal in the function, then pass to copy to funcs, that way you have orignalFromClusterDPA, and updatedFromReconcilerDpa Example: |
Reconcile shouldn't update dpa.. so ignore my comment about patching. |
@shubham-pampattiwar review please. |
95fc7b5
to
59f86fd
Compare
/retest |
@@ -134,7 +131,7 @@ func (r *DPAReconciler) ReconcileBackupStorageLocations(log logr.Logger) (bool, | |||
|
|||
// TODO: check for BSL status condition errors and respond here | |||
if bslSpec.Velero != nil { | |||
err := r.updateBSLFromSpec(&bsl, &dpa, *bslSpec.Velero) | |||
err := r.updateBSLFromSpec(&bsl, dpa, *bslSpec.Velero) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in all DPAReconciler methods, I would remove dpa as a parameter. the functions can access it through r.dpa
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code example of my suggestion
-func (r *DPAReconciler) updateBSLFromSpec(bsl *velerov1.BackupStorageLocation, dpa *oadpv1alpha1.DataProtectionApplication, bslSpec velerov1.BackupStorageLocationSpec) error {
+func (r *DPAReconciler) updateBSLFromSpec(bsl *velerov1.BackupStorageLocation, bslSpec velerov1.BackupStorageLocationSpec) error {
// Set controller reference to Velero controller
- err := controllerutil.SetControllerReference(dpa, bsl, r.Scheme)
+ err := controllerutil.SetControllerReference(r.dpa, bsl, r.Scheme)
if err != nil {
return err
}
...
return nil
}
@stillalearner I want to merge this PR I am working on quickly to already start testing the new non admin feature, but I will let 3 TODOs relating this PR
do you mind rebasing this one after I merge it and fixing those TODOs for me? |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: stillalearner The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unit test failing
/go/src/github.com/openshift/oadp-operator/bin/golangci-lint run
controllers/dpa_controller.go:79:2: import-shadowing: The name 'log' shadows an import name (revive)
log := r.Log.WithValues("dpa", req.NamespacedName)
^
@stillalearner: The following tests failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Issues go stale after 90d of inactivity. Mark the issue as fresh by commenting If this issue is safe to close now please do so with /lifecycle stale |
PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
/remove-lifecycle stale |
Fixed #1128