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

move proxy metrics to a separate server #352

Merged
merged 18 commits into from
Oct 17, 2023

Conversation

ranakan19
Copy link
Contributor

@ranakan19 ranakan19 commented Oct 6, 2023

move proxy metrics to a separate server
host-operator PR - codeready-toolchain/host-operator#884
paired e2e PR - codeready-toolchain/toolchain-e2e#816

@codecov
Copy link

codecov bot commented Oct 6, 2023

Codecov Report

Attention: 7 lines in your changes are missing coverage. Please review.

Files Coverage Δ
pkg/proxy/handlers/spacelister.go 90.66% <71.42%> (-0.41%) ⬇️
pkg/proxy/proxy.go 85.18% <71.42%> (-0.08%) ⬇️
pkg/metrics/metrics.go 90.32% <87.50%> (+2.32%) ⬆️

📢 Thoughts on this report? Let us know!.

Copy link
Contributor

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

We also need to expose the 8082 port in our container:

EXPOSE 8080 8081

@@ -98,6 +98,7 @@ objects:
ports:
- containerPort: 8080
- containerPort: 8081
- containerPort: 8082
Copy link
Contributor

Choose a reason for hiding this comment

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

This file is used only in dev environments. The one which is used in production (and e2e tests) are defined here: https://github.com/codeready-toolchain/host-operator/blob/master/deploy/registration-service/registration-service.yaml
Please create a PR to update that file too.

But what I'm wonder is why the e2e-test still pass? Do we have any e2e tests for this metric service? Without updating https://github.com/codeready-toolchain/host-operator/blob/master/deploy/registration-service/registration-service.yaml the e2e-tests for this PR should fail...

Copy link
Contributor

Choose a reason for hiding this comment

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

could we also add names to the container ports (see for example https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports) to make them more explicit, and reuse these names in the services as well?

Copy link
Contributor

Choose a reason for hiding this comment

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

This file is used only in dev environments.

It's actually not used even in dev environment. This file is a legacy thing from the time when we were able to deploy reg-service on its own - we don't do that anymore (or at least I'm not aware of anyone who would be doing that)

Copy link
Contributor

Choose a reason for hiding this comment

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

but anyway, Alexey is right that you need to create PR in host-repo with this change. Let's do it in two steps:

  1. create PR in host-operator repo changing only the values in the template (I don't think that we verify the actual content of the deployment in e2e tests)
  2. when the host-operator PR is merged, create a PR in e2e tests that will be paired with this reg-service one that will verify that the Service is created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry for the late reply,
@MatousJobanek @alexeykazakov Thanks for your comments and catching the missing host-repo changes. I did have the changes in host-repo, that's how i was able to test it locally indeed, but had missed creating the PR on host-repo. I've updated the host-operator and e2e PR in the description.

@@ -98,6 +98,7 @@ objects:
ports:
- containerPort: 8080
- containerPort: 8081
- containerPort: 8082
Copy link
Contributor

Choose a reason for hiding this comment

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

but anyway, Alexey is right that you need to create PR in host-repo with this change. Let's do it in two steps:

  1. create PR in host-operator repo changing only the values in the template (I don't think that we verify the actual content of the deployment in e2e tests)
  2. when the host-operator PR is merged, create a PR in e2e tests that will be paired with this reg-service one that will verify that the Service is created.


func StartMetricsServer() *http.Server {
// start server
router := echo.New()
Copy link
Contributor

Choose a reason for hiding this comment

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

router looks like a copy-paste zombie from the proxy code :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Comment on lines 89 to 91
// check the status code is what we expect, and the content-type
require.Equal(t, http.StatusOK, rec.Code)
require.Equal(t, "text/plain; version=0.0.4; charset=utf-8", rec.Header().Get("Content-Type"))
Copy link
Contributor

Choose a reason for hiding this comment

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

does it make sense to verify that the body also contains the actual registered metric? you know, just check that the name of the metric is there, no need to verify the actual values...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed

@ranakan19
Copy link
Contributor Author

/retest
host-operator PR merged

Copy link
Contributor

@alexeykazakov alexeykazakov left a comment

Choose a reason for hiding this comment

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

Looks good!

pkg/metrics/metrics_test.go Outdated Show resolved Hide resolved
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
13.2% 13.2% Duplication

Copy link
Contributor

@MatousJobanek MatousJobanek left a comment

Choose a reason for hiding this comment

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

Looks nice. Thanks for the work @ranakan19 👍 🚀

@openshift-ci
Copy link

openshift-ci bot commented Oct 17, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeykazakov, MatousJobanek, ranakan19

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:
  • OWNERS [MatousJobanek,alexeykazakov]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ranakan19 ranakan19 merged commit 5640c6e into codeready-toolchain:master Oct 17, 2023
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants