-
Notifications
You must be signed in to change notification settings - Fork 562
Emit metrics on deprecated APIs dynamically #2155
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
Conversation
…s in the installplan Signed-off-by: Daniel Sover <[email protected]>
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: exdx 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 |
@exdx: This pull request references Bugzilla bug 1958296, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
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. |
@openshift-ci[bot]: GitHub didn't allow me to request PR reviews from the following users: jianzhangbjz. Note that only operator-framework members and repo collaborators can review this PR, and authors cannot review their own PRs. In response to this:
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'm going to remove the "Bug <...>" from the title so the BZ automation doesn't pick this up before a downstream PR has been created. I'll update your description to add a link to the BZ instead. /retitle Emit metrics on deprecated APIs dynamically |
@exdx: No Bugzilla bug is referenced in the title of this pull request. In response to this:
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. |
/retest |
return config | ||
} | ||
|
||
func (w *WarningRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { |
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.
I don't think we can safely read from or close the response body here, at least not without copying to some kind of buffer and setting up a functionally-equivalent ReadCloser on the response before returning it.
Is there a nice way to reliably reverse REST mappings from the request URL path back to a GVK/GVR and name?
Edit: Alternatively, could this copy the warning headers somewhere, then have the step application code (which should know everything about the step it is trying to apply) poll them?
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.
Ah, I was hoping we could do that. But it makes sense, since this is just part of the path of the response, we should not read or close it directly (we could copy the data and do whatever on that though).
I can checkout the idea of reversing the URL to get the resource info (not to unmarshal the response directly).
Putting code into the stepper would work too, but feels like quite a bit of complexity
Name: "install_plan_warnings_count", | ||
Help: "monotonic count of resources created with warnings (for example, deprecation warnings)", | ||
}, | ||
[]string{WARNING_LABEL, NAME_LABEL, NAMESPACE_LABEL, GVK_LABEL}, |
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.
If the warning text, namespace, name, and GVK are all labels, and the values of those labels come from user activity, the risk of blowing up timeseries cardinality feels high to me.
Can most of the specific information go into an Event (possibly associated with the InstallPlan)?
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 certainly a concern, but since we are just alerting here on deprecated objects on creation I'm wondering where the cardinality would truly explode? Is it cases where the installplan includes additional subscriptions from dependency resolution and you basically have an N dimensional install
I was looking to embed things like the installplan name or even better the operator package in the WarningRoundTripper struct, instantiate it in the ExcutePlan()
step with all the info, and then pass it down when creating the clients
@@ -84,6 +88,10 @@ func (b *builder) create(step v1alpha1.Step) (Stepper, error) { | |||
case crdlib.V1Version: | |||
return b.NewCRDV1Step(b.opclient.ApiextensionsInterface().ApiextensionsV1(), &step, manifest), nil | |||
case crdlib.V1Beta1Version: | |||
// Emit error about deprecated API | |||
// This codepath will be removed entirely in 1.22 | |||
metrics.EmitInstallPlanWarning(v1beta1DeprecationWarning, step.Resource.Name, "", |
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.
Why is this special case necessary?
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.
We install CRDs with OLM's client and the scoped client RoundTripper would not apply
@@ -26,6 +26,7 @@ type Factory struct { | |||
// token specified. | |||
func (f *Factory) NewOperatorClient(token string) (client operatorclient.ClientInterface, err error) { | |||
scoped := copy(f.config, token) | |||
scoped = SetWarningRoundTripper(scoped) |
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.
Especially since this is shared between olm and catalog, I think it would be better to inject the warning sniffer instead of setting it up here in scopedclient.
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.
Yep, had the same idea 👍
Signed-off-by: Daniel Sover <[email protected]>
@@ -235,6 +237,14 @@ func (r *AdoptionReconciler) adoptComponents(ctx context.Context, csv *operators | |||
}() | |||
} | |||
|
|||
// alert on components that are deprecated in upcoming kubernetes versions |
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.
Do we need to emit this on every reconciliation? Are we potentially going to start spewing metrics far too frequently in some cases? Can we batch these somehow?
I'm wondering if we should be aggregating this kind of metric and have a separate process that emits them.
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.
Yup, I realized this was an issue with this implementation -- we probably need to move it around somewhere.
Aggregating the metric sounds interest as well, so as not to explode the cardinality?
Closing in favor of another PR. |
Signed-off-by: Daniel Sover [email protected]
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1958296
Description of the change:
Motivation for the change:
Reviewer Checklist
/doc