Skip to content

chore: Get resource from cache instead of APIServer #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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

michaelhtm
Copy link
Member

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.

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.
@ack-prow ack-prow bot requested review from jlbutler and knottnt July 17, 2025 20:04
Copy link

ack-prow bot commented Jul 17, 2025

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dankeshoen!

@michaelhtm
Copy link
Member Author

/test iam-controller-test

@michaelhtm
Copy link
Member Author

/test s3-controller-test

@michaelhtm
Copy link
Member Author

/test sagemaker-controller-test

Copy link

ack-prow bot commented Jul 17, 2025

@michaelhtm: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
verify-attribution 54860f1 link false /test verify-attribution
s3-controller-test 54860f1 link true /test s3-controller-test
sagemaker-controller-test 54860f1 link true /test sagemaker-controller-test

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.

@@ -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
Copy link

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?

Copy link
Member Author

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

Copy link

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?

@michaelhtm
Copy link
Member Author

/hold

@ack-prow ack-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants