-
Notifications
You must be signed in to change notification settings - Fork 361
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
Consider returning empty usage data for /v3/processes/:guid/stats #2227
Comments
We had a discussion around this on Slack, there were concerns about a Now that I read through the API docs, I see we've only added these to the singular
One other thing I realized was that the I think omitting them would align more closely with the existing behavior of the endpoint which provides a very limited set of fields when instances are down. cloud_controller_ng/app/presenters/v3/process_stats_presenter.rb Lines 54 to 63 in 24a27be
cc @sethboyles @Gerg |
Actually, regarding the cloud_controller_ng/lib/cloud_controller/diego/reporters/instances_stats_reporter.rb Lines 54 to 55 in 24a27be
|
Hm, I also thought we had those warnings on more resources besides jobs. Interestingly, we have this method cloud_controller_ng/app/controllers/v3/application_controller.rb Lines 144 to 151 in 24a27be
It was introduced by this PR: https://github.com/cloudfoundry/cloud_controller_ng/pull/1359/files and the only usage of it was removed shortly afterward when that endpoint was made to handle the service broker creation asynchronously: So we have this method that is unused---BUT the CLI apparently still has code in it to print out these header warnings when it sees them. on a bosh-lite I added a warning like this:
And when running a CLI command it gets printed:
I haven't had a chance to think too much about this pattern and whether or not its preferable to the above. But it is an option... |
- this change rescues errors from log-cache and metric-proxy and passes them up as warnings to callers instead of exceptions so that the stats endpoint can continue to function on a best-effort basis - on /v3/processes/:guid/stats these warnings are included in a new "warnings" key on the response, on v2 they are ignored - addresses #2227 Authored-by: Tim Downey <tdowney@vmware.com>
@sethboyles I created a draft PR to get some initial feedback: I had to jump through some hoops to get the "warning messages" passed up high enough for the controllers to act on them and ended up using Go style multi-value returns to do so. It's not the most idiomatic Ruby I've written so I'd appreciate y'all's thoughts on that. I'm also happy to use the If this approach seems fine, though, I'll probably clean it up a bit further and add a commit to tweak the docs and remove the now unused |
- this change rescues errors from log-cache and metric-proxy and passes them up as warnings to callers instead of exceptions so that the stats endpoint can continue to function on a best-effort basis - on /v3/processes/:guid/stats these warnings are included in the 'X-Cf-Warnings' header - addresses #2227 Authored-by: Tim Downey <tdowney@vmware.com>
- this temporary config flag was used to ignore server unavailable errors coming back from log-cache (or metric-proxy in cf-for-k8s) - given the change proposed in #2227 to rescue more errors and serve partial stats responses this config is no longer necessary Authored-by: Tim Downey <tdowney@vmware.com>
In #2227 we updated the Process Stats endpoint to be able to return partial responses (with a warning) when the stats server is unavailable. Authored-by: Tim Downey <tdowney@vmware.com>
@sethboyles one annoying thing about the warning I just discovered is that the CLI emits it to stdout (I had assumed it was going to stderr) -- even on So if you've got something trying to parse this as json it ends up choking on
This is probably more of a CLI issue, but it was a bit unexpected. |
Ah, interesting. Is this just particular to the
this is using CF CLI v7 If so, might be worth opening an issue for the cf cli |
- Since the `/v3/processes/:guid/stats endpoint now may set an `X-Cf-Warnings` header (see cloudfoundry/cloud_controller_ng#2227), the CLI may return the contents of this header along with the endpoint's regular JSON response which causes parsing errors in the BARAs - Logged cloudfoundry/cli#2164 with the CLI to make it so that header isn't printed to `stdout` for this command, but until then we can just switch to use a regular http client to fetch this endpoint [#177518468](https://www.pivotaltracker.com/story/show/177518468) Authored-by: Tim Downey <tdowney@vmware.com>
This was release in 1.110 (though it seems to have escaped the release notes) |
Thanks for submitting an issue to
cloud_controller_ng
. We are always trying to improve! To help us, please fill out the following template.Issue
When
log-cache
(ormetric-proxy
on cf-for-k8s) is unavailable or returns a bad response for a particular process the entire/v3/processes/:guid/stats
endpoint will exit with an error.Context
This behavior is unfortunate for clients who do not care about process metrics and instead are using the endpoint for other information (e.g. is my process running? what ports is my process listening on?). Ideally the endpoint could continue to respond with the information it is able to provide when the platform is degraded.
Steps to Reproduce
On cf-for-k8s you can easily reproduce this behavior by running
cf restart
on an app in a loops. It fails roughly every 10 restarts sincemetric-proxy
has difficulty fetching metrics from the Kubernetes API while pod containers are being churned.More easily you can reproduce this by explicitly raising an error in the log-cache client in this method:
cloud_controller_ng/lib/logcache/client.rb
Line 32 in 637fe7d
Expected result
Request:
Response:
or
Current result
An error is returned from the CF API. Clients typically do not handle this well and it results in failed
cf push
andcf restart
commands for users.Possible Fix
One potential fix is to return
0
s for the values since this is what we do for empty envelopes. However, in a recent story (https://www.pivotaltracker.com/n/projects/966314/stories/177066349) it was pointed out that his is not ideal since 0 is a valid value for these metrics by @jenspinney. I agree that that's not ideal. Alternatively you could use a sentinel value integer like-1
, but I imagine clients that are making decisions based on this data might not handle that well and it may result in odd bugs.I think the safest and most semantic fix here is to return an empty
usage
array. Some clients may not handle that correctly, but ideally it would manifest as a response parsing error rather than a mathematical error.Alternatively the onus could be put on the clients to retry when they get errors back from this endpoint. However, if log-cache is unavailable for long periods of time, this will not be much help. Since this endpoint is in the critical path for
cf push
andcf (re)start
I think it makes the most sense to try and improve the experience in Cloud Controller.For good measure, I did create an issue with the CLI, though.
cloudfoundry/cli#2160
The text was updated successfully, but these errors were encountered: