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

pkg/metrics: Allow multi port metrics Service creation #1560

Merged
merged 8 commits into from
Jun 25, 2019

Conversation

lilic
Copy link
Member

@lilic lilic commented Jun 14, 2019

Motivation for the change:

With the recent addition of Custom Resource metrics we need to expose the port in the metrics Service. This also helps users who want to expose their own metrics ports in a Service as they can just pass in another port.

Note: We also changed the name of the Service that is being created by appending -metrics to the operator name, this makes it self descriptive as we did have questions what is this service for.

TODO:

  • adjust docs to match the changes to the functions

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jun 14, 2019
@lilic lilic changed the title pkg/metrics: Allow multi port metrics Service creation WIP: pkg/metrics: Allow multi port metrics Service creation Jun 14, 2019
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jun 14, 2019
@lilic lilic force-pushed the change-metrics-service branch 2 times, most recently from de72be8 to 13c609c Compare June 14, 2019 14:24
Copy link
Member

@shawn-hurley shawn-hurley left a comment

Choose a reason for hiding this comment

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

I think this is good from a code prespective. I just have 1 question about the MetricsService type.

WDYT of just using the ServicePort type there?

@lilic
Copy link
Member Author

lilic commented Jun 19, 2019

@shawn-hurley

WDYT of just using the ServicePort type there?

My reasoning behind is to make it easy for users to create the Services, I think those that know how to fill in the ServicePort (e.g. the TargetPort, NodePort, etc.) can create the Service themselves. This is meant to serve users that want to expose additional metrics endpoints, we had a bunch of requests for that, and our metrics endpoints. But am opening to that idea if everyone else thinks so, of course!

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 19, 2019
@lilic lilic changed the title WIP: pkg/metrics: Allow multi port metrics Service creation pkg/metrics: Allow multi port metrics Service creation Jun 19, 2019
@openshift-ci-robot openshift-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 19, 2019
@joelanford
Copy link
Member

I would tend to agree with Shawn that the MetricsService type is probably unnecessary. Here's what it would look like using ServicePorts directly:

	// Add to the below struct any other metrics ports you want to expose.
	servicePorts := []corev1.ServicePort{
		{ Name: metrics.CRPortName, TargetPort: intstr.FromInt(int(metricsPort))},
	}

	// Create Service object to expose the metrics port(s).
	_, err = metrics.CreateMetricsService(ctx, servicePorts)

To me, that seems simple enough for new users and also slightly more useful for users looking to do something slightly more custom for their metrics service ports.

@lilic lilic force-pushed the change-metrics-service branch 6 times, most recently from 524725e to dfcaafc Compare June 20, 2019 13:24
@lilic
Copy link
Member Author

lilic commented Jun 20, 2019

@joelanford @shawn-hurley I made the suggested change, the additional fields were needed otherwise Service cannot be created. PTAL.

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

Can you update the CHANGELOG and mention the removed PrometheusPortName and ExposeMetricsPort identifiers, and the added OperatorPortName, CRPortName, and CreateMetricsService identifiers?

@hasbro17 Is there a migration guide that needs to mention this change?

"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
"k8s.io/apimachinery/pkg/util/intstr"
Copy link
Member

Choose a reason for hiding this comment

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

This is a duplicate of line 62, so it can be removed.

@hasbro17
Copy link
Contributor

@joelanford Still working on the migration guide but yes for v0.8.1->v0.9.x we'll need to note down these signature changes.
So long as they're marked as breaking changes in the CHANGELOG I'll be able to add them in later.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 24, 2019
@lilic
Copy link
Member Author

lilic commented Jun 24, 2019

@hasbro17 @joelanford I added things to the CHANGELOG, please have a look at that, if the wording is clear enough, thanks!

@lilic
Copy link
Member Author

lilic commented Jun 24, 2019

/test marker

@lilic
Copy link
Member Author

lilic commented Jun 24, 2019

No idea why marker test is failing here, as the URLs work for me 🤔

@lilic
Copy link
Member Author

lilic commented Jun 24, 2019

/test marker

CHANGELOG.md Outdated

### Deprecated

### Removed

- The SDK no longer depends on a `vendor/` directory to manage dependencies *only if* using [Go modules](https://github.com/golang/go/wiki/Modules). The SDK and operator projects will only use vendoring if using `dep`, or modules and a `vendor/` dir is present. ([#1519](https://github.com/operator-framework/operator-sdk/pull/1519))
- `ExposeMetricsPort` is now depracted and was replaced with `CreateMetricsService()` function. `PrometheusPortName` constant is replaced with `OperatorPortName`. ([#1560](https://github.com/operator-framework/operator-sdk/pull/1560))
Copy link
Member

@joelanford joelanford Jun 24, 2019

Choose a reason for hiding this comment

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

Deprecated means that the thing still exists and will be removed in a future version, right? In this PR, we're actually removing it without deprecating it.

So that leads me to a question: should we actually deprecate ExposeMetricsPort and leave it in place for now?

Copy link
Member

Choose a reason for hiding this comment

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

we are pre 1.0 I think it is ok to deprecate and replace in a single release IMO. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we said we are making breaking changes until the 1.0 release yes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe we could make it more in bold in the CHANGELOG? Also with the migration doc coming up that you mention @joelanford it should be easy for people to migrate IMO.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think it's fine to remove it. Just wanted to make sure we were all in agreement to do that. I would suggest:

  • Prefixing with **Breaking change**: like we've done before
  • s/deprecated/removed/ to make it clear the ExposeMetricsPort is no longer present.

WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

sgtm, done!

@shawn-hurley
Copy link
Member

/retest

Copy link
Member

@joelanford joelanford left a comment

Choose a reason for hiding this comment

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

/approve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants