fix(metrics-operator): provide more information for dynatrace api error
Description
This PR adds more information to the dynatrace api error response
Fixes #2790
How to test
Please describe how to run the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also provide information about any automatic tests that you added.
- [ ] Manual Test A
- [x] Unit Test B
- [ ] Integration Test C
Checklist
- [x] My PR fulfills the Definition of Done of the corresponding issue and not more (or parts if the issue is separated into multiple PRs)
- [x] I used descriptive commit messages to help reviewers understand my thought process
- [x] I signed off all my commits according to the Developer Certificate of Origin (DCO) see Contribution Guide
- [x] My PR title is formatted according to the semantic PR conventions described in the Contribution Guide
- [x] My code follows the style guidelines of this project (golangci-lint passes, YAMLLint passes)
- [ ] I regenerated the auto-generated docs for Helm and the CRD documentation (if applicable)
- [x] I have performed a self-review of my code
- [ ] I have made corresponding changes to the documentation (if needed)
- [ ] My changes result in all-green PR checks (first-time contributors need to ask a maintainer to approve their test runs)
- [x] New and existing unit and integration tests pass locally with my changes
Codecov Report
Attention: Patch coverage is 60.00000% with 4 lines in your changes are missing coverage. Please review.
Project coverage is 85.32%. Comparing base (
e048679) to head (131675f).
:exclamation: Current head 131675f differs from pull request most recent head b34e7ab. Consider uploading reports for the commit b34e7ab to get more accurate results
Additional details and impacted files
@@ Coverage Diff @@
## main #2885 +/- ##
==========================================
- Coverage 85.36% 85.32% -0.05%
==========================================
Files 167 167
Lines 7412 7412
==========================================
- Hits 6327 6324 -3
- Misses 798 800 +2
- Partials 287 288 +1
| Files | Coverage Δ | |
|---|---|---|
| ...ollers/common/providers/dynatrace/client/client.go | 72.72% <60.00%> (ø) |
... and 1 file with indirect coverage changes
| Flag | Coverage Δ | |
|---|---|---|
| certificate-operator | 69.23% <ø> (ø) |
|
| component-tests | 58.53% <ø> (-0.25%) |
:arrow_down: |
| lifecycle-operator | 83.46% <ø> (ø) |
|
| metrics-operator | 88.32% <60.00%> (ø) |
|
| scheduler | 34.74% <ø> (ø) |
Flags with carried forward coverage won't be shown. Click here to find out more.
Hey @Vickysomtee the ticket requests a Chainsaw test using mockserver, you can copy the implementation of this test but change it for a failing http response to show what would be printed by the operator.
The idea is that the mockserver configuration can return a bad http code, and the result of the operator for example a keptn metric should be the error message you added.
Hey @Vickysomtee the ticket requests a Kuttl test using mockserver, you can copy the implementation of this test but change it for a failing http response to show what would be printed by the operator.
The idea is that the mockserver configuration can return a bad http code, and the result of the operator for example a keptn metric should be the error message you added.
@RealAnna can you check the link in your comment? It links to a folder. Did you intend to link to a folder or a file
Also, just to note, I didn't introduce new error message. I only added statusCode
Hey @Vickysomtee indeed, I had in mind you changed also the printed message but apparently not... Anyhow line 106, 111 and 127 could use coverage by unit test. For the chainsaw test this is indeed a folder with multiple files, some file declare what the test wll install on the test environment and the other assert the expected result. YOu can have a look at how it works here
Hi @Vickysomtee, any news on this one? feel free to reach out if you have any questions
Hi @Vickysomtee, any news on this one? feel free to reach out if you have any questions
@bacherfl I had a very tight schedule this past weeks. I am settled now, and I will round up this issue ASAP.
Hi @Vickysomtee any updates on this PR?
Hi @Vickysomtee any updates on this PR?
Hey @odubajDT I think I am done with the implementation. @RealAnna was helping out with the chainsaw test but it seems she currently isn't available or a little bit busy.
@Vickysomtee seems like the pr needs a rebase since the go version has been upgraded, after that I will run again the test to check if any API error is propagated like it should
@Vickysomtee seems like the pr needs a rebase since the go version has been upgraded, after that I will run again the test to check if any API error is propagated like it should
@RealAnna This is sorted
@Vickysomtee seems like the pr needs a rebase since the go version has been upgraded, after that I will run again the test to check if any API error is propagated like it should
@RealAnna This is sorted
Please adapt the integration tests (mentioned here) and also the unit tests (mentioned here) according to the comments
@Vickysomtee your unit tests are now failing, could you debug them? Also the integration test shows a strange error "unexpected end of JSON input" I would expect that the API error is forwarded.. maybe you need to doublechek your configuration of mock server:
in the logs I see that the actual query sent to the mock is:
`request:
{
"method" : "GET",
"path" : "/api/v2/metrics/query",
"queryStringParameters" : {
"metricSelector" : [ "query" ]
},
"headers" : {
"x-forwarded-by" : [ "MockServer_99f6f711-462f-4a60-9432-303a23ddd8ec" ],
"host" : [ "mockserver.chainsaw-epic-spaniel.svc.cluster.local:1080" ],
"content-length" : [ "0" ],
"connection" : [ "keep-alive" ],
"accept-encoding" : [ "gzip,deflate" ],
"User-Agent" : [ "Go-http-client/1.1" ],
"Authorization" : [ "Api-Token token: mytoken" ]
},
"keepAlive" : true,
"secure" : false,
"remoteAddress" : "10.244.0.1"
}
you should try to adapt the configuration so that it matches it
@Vickysomtee any news on this?
@Vickysomtee any news on this?
@odubajDT I will look into between today and tomorrow
@Vickysomtee your unit tests are now failing, could you debug them? Also the integration test shows a strange error "unexpected end of JSON input" I would expect that the API error is forwarded.. maybe you need to doublechek your configuration of mock server:
in the logs I see that the actual query sent to the mock is: `request: { "method" : "GET", "path" : "/api/v2/metrics/query", "queryStringParameters" : { "metricSelector" : [ "query" ] }, "headers" : { "x-forwarded-by" : [ "MockServer_99f6f711-462f-4a60-9432-303a23ddd8ec" ], "host" : [ "mockserver.chainsaw-epic-spaniel.svc.cluster.local:1080" ], "content-length" : [ "0" ], "connection" : [ "keep-alive" ], "accept-encoding" : [ "gzip,deflate" ], "User-Agent" : [ "Go-http-client/1.1" ], "Authorization" : [ "Api-Token token: mytoken" ] }, "keepAlive" : true, "secure" : false, "remoteAddress" : "10.244.0.1" }you should try to adapt the configuration so that it matches it
@RealAnna Should I include this headers section in the mock request as well?
Please adapt the integration tests (mentioned here) and also the unit tests (mentioned here) according to the comments
@odubajDT For the unit test, I informed @RealAnna that no new error message was introduced in the PR. Only statusCode was added. For integration test, still figuring it out.
@Vickysomtee your unit tests are now failing, could you debug them? Also the integration test shows a strange error "unexpected end of JSON input" I would expect that the API error is forwarded.. maybe you need to doublechek your configuration of mock server:
in the logs I see that the actual query sent to the mock is: `request: { "method" : "GET", "path" : "/api/v2/metrics/query", "queryStringParameters" : { "metricSelector" : [ "query" ] }, "headers" : { "x-forwarded-by" : [ "MockServer_99f6f711-462f-4a60-9432-303a23ddd8ec" ], "host" : [ "mockserver.chainsaw-epic-spaniel.svc.cluster.local:1080" ], "content-length" : [ "0" ], "connection" : [ "keep-alive" ], "accept-encoding" : [ "gzip,deflate" ], "User-Agent" : [ "Go-http-client/1.1" ], "Authorization" : [ "Api-Token token: mytoken" ] }, "keepAlive" : true, "secure" : false, "remoteAddress" : "10.244.0.1" }you should try to adapt the configuration so that it matches it
@RealAnna Should I include this headers section in the mock request as well?
Yes the mock should match what I pasted here 👍
Yes the mock should match what I pasted here 👍
@RealAnna Done!
Hello @RealAnna can you help review again?
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code
closing due to inactivity