Skip to content

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

Closed
wants to merge 2 commits into from

Conversation

exdx
Copy link
Member

@exdx exdx commented May 10, 2021

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

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive

@exdx exdx requested review from benluddy and kevinrizza May 10, 2021 21:15
@openshift-ci
Copy link

openshift-ci bot commented May 10, 2021

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label May 10, 2021
@openshift-ci
Copy link

openshift-ci bot commented May 10, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: exdx
To complete the pull request process, please assign ecordell after the PR has been reviewed.
You can assign the PR to them by writing /assign @ecordell in a comment when ready.

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

@openshift-ci openshift-ci bot requested review from dinhxuanvu and njhale May 10, 2021 21:15
@openshift-ci openshift-ci bot added bugzilla/severity-urgent Referenced Bugzilla bug's severity is urgent for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 10, 2021
@openshift-ci
Copy link

openshift-ci bot commented May 10, 2021

@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
  • bug is open, matching expected state (open)
  • bug target release (4.8.0) matches configured target release for branch (4.8.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @jianzhangbjz

In response to this:

Bug 1958296: emit metrics on deprecated APIs dynamically

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

openshift-ci bot commented May 10, 2021

@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:

@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
  • bug is open, matching expected state (open)
  • bug target release (4.8.0) matches configured target release for branch (4.8.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @jianzhangbjz

In response to this:

Bug 1958296: emit metrics on deprecated APIs dynamically

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.

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.

@timflannagan
Copy link
Member

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

@openshift-ci openshift-ci bot changed the title Bug 1958296: emit metrics on deprecated APIs dynamically Emit metrics on deprecated APIs dynamically May 11, 2021
@openshift-ci
Copy link

openshift-ci bot commented May 11, 2021

@exdx: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

In response to this:

Emit metrics on deprecated APIs dynamically

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 openshift-ci bot removed bugzilla/severity-urgent Referenced Bugzilla bug's severity is urgent for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels May 11, 2021
@timflannagan
Copy link
Member

/retest

return config
}

func (w *WarningRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
Copy link
Contributor

@benluddy benluddy May 11, 2021

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?

Copy link
Member Author

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},
Copy link
Contributor

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)?

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 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, "",
Copy link
Contributor

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?

Copy link
Member Author

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)
Copy link
Contributor

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.

Copy link
Member Author

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 👍

@@ -235,6 +237,14 @@ func (r *AdoptionReconciler) adoptComponents(ctx context.Context, csv *operators
}()
}

// alert on components that are deprecated in upcoming kubernetes versions
Copy link
Member

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.

Copy link
Member Author

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?

@exdx
Copy link
Member Author

exdx commented Jun 1, 2021

Closing in favor of another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants