-
Notifications
You must be signed in to change notification settings - Fork 176
chore: Use client instead of APIReader + Add observedGeneration to status Conditions #193
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
base: main
Are you sure you want to change the base?
chore: Use client instead of APIReader + Add observedGeneration to status Conditions #193
Conversation
Currently in ACK, at the beginning of the Reconciler for each event, we get the resource from the k8s APIServer. This is an unecessary call, as the latest object that triggered the reconciler is already stored in the informers cache. With this change, we will be retrieving the resource from the cache instead of the APIServer.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: michaelhtm The full list of commands accepted by this bot can be found here. The pull request process is described 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.
Dankeshoen!
/test iam-controller-test |
/test s3-controller-test |
/test sagemaker-controller-test |
@@ -197,15 +198,15 @@ func (r *fieldExportReconciler) getFieldExport( | |||
req ctrlrt.Request, | |||
) (*ackv1alpha1.FieldExport, error) { | |||
ro := &ackv1alpha1.FieldExport{} | |||
// Here we use k8s APIReader to read the k8s object by making the | |||
// Here we use k8s ackResourceCache to read the k8s object by making the | |||
// direct call to k8s apiserver instead of using k8sClient. | |||
// The reason is that k8sClient uses a cache and sometimes k8sClient can | |||
// return stale copy of object. | |||
// It is okay to make direct call to k8s apiserver because we are only | |||
// making single read call for complete reconciler loop. | |||
// See following issue for more details: | |||
// https://github.com/aws-controllers-k8s/community/issues/894 |
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.
Is the problem described in this issue no longer relevant?
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.
It's not related to a problem..it's mainly just an optimization.
I'll expand more on it in a community PR
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.
From this comment it sounds like the use of direct server calls was to avoid duplicate create calls. Or are you referring to this change when you say optimization?
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.
@michaelhtm I think this might create issues for us in the current implementation at least. I think atleast during creates there should be a mechanism to verify if resources are created. Updates will be eventually consistent which is fine.
/hold |
This PR should be release along with the observed generation condition work |
Observed Generation is a kubernetes standard that persists the latest reconciled generation (metadata.generation) in the resource status condition
Using Controller-Runtime Client is safer in general, as it will attempt to read objects from the APIServer if it was not cached in locally. For example, when using resource references, or using ACK to reference secrets, we may need to read these objects from the APIServer.
/retest |
@michaelhtm: The following test 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/test-infra repository. I understand the commands that are listed here. |
Description of changes:
Currently in ACK, at the beginning of the Reconciler for each event, we
get the resource from the k8s APIServer. This is an unecessary call, as
the latest object that triggered the reconciler is already stored in the
informers cache.
With this change, we will be retrieving the resource from the cache
instead of the APIServer.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.