Skip to content
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

Perform discovery API calls only as needed #39

Conversation

mprahl
Copy link
Member

@mprahl mprahl commented Mar 22, 2023

This commit changes the discovery REST mapper that was used to be targeted to
that specific resource version.

This is to reduce load on the Kubernetes API as well as to reduce the chance
of long delays due to queries per second (QPS) exceeding the default limit.

An additional commit was added to prevent watches being created on Gatekeeper constraints without the corresponding CRD installed.

Other commits are to address flaky tests.

Relates:
https://issues.redhat.com/browse/ACM-4518

@mprahl
Copy link
Member Author

mprahl commented Mar 22, 2023

@dhaiducek and @JustinKuli I think this should help with the flaky tests.

@mprahl
Copy link
Member Author

mprahl commented Mar 22, 2023

/hold the tests seem to have a lot of client throttling log messages so it may not work as I had hoped

@mprahl
Copy link
Member Author

mprahl commented Mar 22, 2023

/unhold

@JustinKuli and @dhaiducek I figured out a better approach.

@mprahl
Copy link
Member Author

mprahl commented Mar 22, 2023

/hold for better error handling

@mprahl
Copy link
Member Author

mprahl commented Mar 22, 2023

/unhold

@mprahl
Copy link
Member Author

mprahl commented Mar 22, 2023

@dhaiducek and @JustinKuli sorry for the noise. This is now ready for review.

Copy link
Member

@JustinKuli JustinKuli left a comment

Choose a reason for hiding this comment

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

How will we measure if this is better than the old implementation?

}
}

return schema.GroupVersionResource{}, false, fmt.Errorf("%w: %s", errNoVersionedResource, gvk.String())
Copy link
Member

Choose a reason for hiding this comment

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

It might be nice to slightly distinguish between this error case and the NotFound case earlier. I can imagine a debug session from logs where these two cases being identical could be frustrating.

This commit changes the discovery REST mapper that was used to be targeted to
that specific resource version.

This is to reduce load on the Kubernetes API as well as to reduce the chance
of long delays due to queries per second (QPS) exceeding the default limit.

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
This should address the flakiness.

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
Prior to this, dynamic watch library was instructed to watch constraints
even when the corresponding ConstraintTemplate hadn't had a CRD
generated yet. This caused the dynamic watch library to constantly
refresh its discovery metadata, which is taxing to the Kubernetes API
and can cause client throttling.

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
This will give us more control of how the events are sent and perhaps
reduce flakiness.

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
mprahl added a commit to mprahl/kubernetes-dependency-watches that referenced this pull request Mar 23, 2023
Generating a REST mapper is very expensive on the Kubernetes API. This
approach just gets the information needed for the particular watch
request and then caches the information.

This relates to this PR:
open-cluster-management-io/governance-policy-framework-addon#39

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
@mprahl
Copy link
Member Author

mprahl commented Mar 23, 2023

@dhaiducek and @JustinKuli note that if we merge this related PR, case12 would be much faster since it wouldn't cause the discovery information to be refreshed every time we try to create a watch on a Kind that does not exist:
stolostron/kubernetes-dependency-watches#8

@openshift-ci
Copy link

openshift-ci bot commented Mar 23, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JustinKuli, mprahl

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

@openshift-merge-robot openshift-merge-robot merged commit 8362ff5 into open-cluster-management-io:main Mar 23, 2023
mprahl added a commit to mprahl/kubernetes-dependency-watches that referenced this pull request Mar 27, 2023
Generating a REST mapper is very expensive on the Kubernetes API. This
approach just gets the information needed for the particular watch
request and then caches the information.

This relates to this PR:
open-cluster-management-io/governance-policy-framework-addon#39

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
openshift-merge-robot pushed a commit to stolostron/kubernetes-dependency-watches that referenced this pull request Mar 27, 2023
Generating a REST mapper is very expensive on the Kubernetes API. This
approach just gets the information needed for the particular watch
request and then caches the information.

This relates to this PR:
open-cluster-management-io/governance-policy-framework-addon#39

Signed-off-by: mprahl <mprahl@users.noreply.github.com>
mprahl pushed a commit to mprahl/governance-policy-framework-addon that referenced this pull request Apr 19, 2023
…cy (open-cluster-management-io#39)

Adds a label to policy templates that are created as a child of a policy, then compares the policy templates actually contained in that policy to all templates with the parent policy label to determine if templates have been renamed or removed from the parent. The template sync will then clean up any policy templates that are not being managed by the parent policy that created them.

refs:
- https://issues.redhat.com/browse/ACM-3049?filter=-1

Signed-off-by: Will Kutler <wkutler@redhat.com>
(cherry picked from commit 2661cb2)

Co-authored-by: Will Kutler <wkutler@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants