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

Refactor metrics merging to work with endpoints-controller #469

Merged
merged 1 commit into from
Apr 6, 2021

Conversation

ndhanushkodi
Copy link
Contributor

@ndhanushkodi ndhanushkodi commented Mar 31, 2021

Changes proposed in this PR:

  • Refactor metrics merging to work with endpoints-controller

    Previously, all metrics configuration was dealt with in the mutating
    webhook handler. Now, since service/proxy registration happens in
    endpoints-controller, some of the metrics configuration needs to be used
    in endpoints-controller as well. There is still some functionality in
    the handler that also needs metrics configuration, such as adding
    prometheus annotations and running the consul sidecar.

    This refactor pulls out common configuration for metrics into a
    MetricsConfiguration struct and adds the methods for getting values from
    flags and annotations to that struct, so it can be commonly used between
    endpoints-controller and the webhook handler.

I wasn't able to E2E test this due to consul-k8s and consul-helm being incompatible on the feature-tproxy branch. Once we make the Helm PR for feature-tproxy, we should have confidence that the acceptance tests cover the metrics merging functionality.

How I've tested this PR:

How I expect reviewers to test this PR:

  • Code Review

Checklist:

  • Tests added

@ndhanushkodi ndhanushkodi changed the base branch from master to feature-tproxy March 31, 2021 05:43
@ndhanushkodi ndhanushkodi requested review from a team, lkysow and thisisnotashwin and removed request for a team March 31, 2021 05:45
Copy link
Contributor

@thisisnotashwin thisisnotashwin left a comment

Choose a reason for hiding this comment

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

My thoughts: I really like the direction of this refactor/cleanup!! In terms of naming, i'd migrate InjectConfiguration -> MetricsConfiguration given the specificity of the config.

I also potentially like grouping all of our requests and limits into a similar struct (not a part of this change here, but more as a future adoption of this pattern of grouping related entities into their own struct and file for readability.

connect-inject/common_inject_configuration.go Outdated Show resolved Hide resolved
connect-inject/common_inject_configuration.go Outdated Show resolved Hide resolved
connect-inject/consul_sidecar.go Outdated Show resolved Hide resolved
@kschoche
Copy link
Contributor

kschoche commented Apr 1, 2021

I really like this, great work so far. Echoing a few of the naming related things Ashwin mentioned otherwise I think it's a good approach.

@ndhanushkodi ndhanushkodi force-pushed the metrics-merging-on-tproxy branch from d973a84 to 150750c Compare April 5, 2021 04:43
@ndhanushkodi ndhanushkodi changed the title Refactor metrics merging to work with endpoints-controller (looking for initial thoughts, naming suggestions) Refactor metrics merging to work with endpoints-controller Apr 5, 2021
@ndhanushkodi
Copy link
Contributor Author

Thanks @thisisnotashwin and @kschoche for your feedback!! I've made edits based on this and cleaned up the PR, so re-requesting your reviews for this more final version.

@ndhanushkodi ndhanushkodi requested review from kschoche and thisisnotashwin and removed request for lkysow April 5, 2021 04:46
Copy link
Contributor

@thisisnotashwin thisisnotashwin left a comment

Choose a reason for hiding this comment

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

This looks really good. Have a few suggestions but it should be close to ready after those changes.

connect-inject/metrics_configuration.go Outdated Show resolved Hide resolved
connect-inject/handler.go Outdated Show resolved Hide resolved
Copy link
Member

@lkysow lkysow left a comment

Choose a reason for hiding this comment

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

LGTM

connect-inject/handler.go Outdated Show resolved Hide resolved
connect-inject/metrics_configuration.go Outdated Show resolved Hide resolved
connect-inject/consul_sidecar_test.go Show resolved Hide resolved
connect-inject/container_init.go Outdated Show resolved Hide resolved
connect-inject/endpoints_controller.go Outdated Show resolved Hide resolved
connect-inject/endpoints_controller.go Outdated Show resolved Hide resolved
connect-inject/endpoints_controller.go Outdated Show resolved Hide resolved
@ndhanushkodi ndhanushkodi force-pushed the metrics-merging-on-tproxy branch from 150750c to 2466746 Compare April 6, 2021 20:30
fmt.Sprintf("-service-metrics-path=%s", serviceMetricsPath),
fmt.Sprintf("-merged-metrics-port=%s", metricsPorts.mergedPort),
fmt.Sprintf("-service-metrics-port=%s", metricsPorts.servicePort),
fmt.Sprintf("-service-metrics-path=%s", metricsPorts.servicePath),
Copy link
Contributor

Choose a reason for hiding this comment

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

nice, I ❤️ this cleanup!

Copy link
Contributor

@kschoche kschoche left a comment

Choose a reason for hiding this comment

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

Awesome stuff here! I love the cleanup that you did.
I left a few nonblocking comments but it looks great!

Previously, all metrics configuration was dealt with in the mutating
webhook handler. Now, since service/proxy registration happens in
endpoints-controller, some of the metrics configuration needs to be used
in endpoints-controller as well. There is still some functionality in
the handler that also needs metrics configuration, such as adding
prometheus annotations and running the consul sidecar.

This refactor pulls out common configuration for metrics into a
MetricsConfig struct and adds the methods for getting values from
flags and annotations to that struct, so it can be commonly used between
endpoints-controller and the webhook handler.
@ndhanushkodi ndhanushkodi force-pushed the metrics-merging-on-tproxy branch from 2466746 to 67d9c5f Compare April 6, 2021 21:22
@ndhanushkodi ndhanushkodi merged commit e2eada2 into feature-tproxy Apr 6, 2021
@ndhanushkodi ndhanushkodi deleted the metrics-merging-on-tproxy branch April 6, 2021 22:05
ishustava pushed a commit that referenced this pull request Apr 14, 2021
Previously, all metrics configuration was dealt with in the mutating
webhook handler. Now, since service/proxy registration happens in
endpoints-controller, some of the metrics configuration needs to be used
in endpoints-controller as well. There is still some functionality in
the handler that also needs metrics configuration, such as adding
prometheus annotations and running the consul sidecar.

This refactor pulls out common configuration for metrics into a
MetricsConfig struct and adds the methods for getting values from
flags and annotations to that struct, so it can be commonly used between
endpoints-controller and the webhook handler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants