You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
The HTTP health check filter relies on the presence of the following stats: membership_total, membership_healthy, and membership_degraded. Running a configuration that filters out these stats will cause the filter to not work properly. Like #9856, this falls into the category of using stats for control flow.
Heh. I don't think this is much of a slog; it's just a question of whether we think it's worthwhile to pursue #14120 .
I'm of too minds. On one hand, it seems like a reasonable workaround to this problem, but it's also still playing whack a mole. I'm not sure what the best solution here is tbh.
One other that I just thought of is to add pattern-based overrides into the matcher system. This has the advantage that the complexity stays purely in the stats-matcher infrastructure, rather than bleeding into the API.
One disadvantage of that is that the patterns might be a little imprecise and potentially force-enable unrelated stats. But enabling a few extra stats might not catastrophic.
Arguably a fatal disadvantage is that it centralizes the enumeration of stats that must be force-enabled, as the stats-matcher object may not be accessible to every subsystem or extension that needs to force-enable a stat.
Maybe the simplest option is to just disallow this scenario with doc, and wherever we have code that relies on a stat for functionality, we just add a parallel atomic, even though there's some duplication that way.
I thought of another option, which would be a lot of toil to implement, but might be easier to maintain: to disallow reading the value() of a stat from production code.
There are a few hurdles to doing this:
legit uses of reading value() from stats in production, such as in the implementation of stats sinks and the admin console, where it's expected behavior for those to just return 0 if the stats were disallowed
many many tests that call value().
There are a few possible solutions to dealing with this that involve changing a lot of code. The first I thought of is:
Make value() be protected in the stats classes, and use friend to allow admin/stats-sink access
Add a method valueForTest to counters/gauges/text-readout which is public, but use lint to avoid calling that from production code
This is a bit of toil because it involves changing a huge number of lines of unit tests, and that. will may make future backports fail, adding further toil. But maybe that's the best long term solution.
A variant on that is to use a testing peer class for looking at stats in tests, rather than having a specially-named method. That avoids relying on lint, but involves slightly more toil in doing the conversion.
So I agree ^ is probably the correct solution, as it would actually fix the problem for real versus still having to play whack a mole all the time. I'm not sure if it's worth the effort vs. just fixing issues as the come up.
Activity
mattklein123 commentedon Jan 8, 2021
cc @jmarantz another one of these. If you are looking for another slog project this general topic would be a good one to go after. :)
jmarantz commentedon Jan 9, 2021
Heh. I don't think this is much of a slog; it's just a question of whether we think it's worthwhile to pursue #14120 .
mattklein123 commentedon Jan 10, 2021
I'm of too minds. On one hand, it seems like a reasonable workaround to this problem, but it's also still playing whack a mole. I'm not sure what the best solution here is tbh.
jmarantz commentedon Jan 11, 2021
One other that I just thought of is to add pattern-based overrides into the matcher system. This has the advantage that the complexity stays purely in the stats-matcher infrastructure, rather than bleeding into the API.
One disadvantage of that is that the patterns might be a little imprecise and potentially force-enable unrelated stats. But enabling a few extra stats might not catastrophic.
Arguably a fatal disadvantage is that it centralizes the enumeration of stats that must be force-enabled, as the stats-matcher object may not be accessible to every subsystem or extension that needs to force-enable a stat.
So IMO #14120 seems more maintainable than that.
Maybe the simplest option is to just disallow this scenario with doc, and wherever we have code that relies on a stat for functionality, we just add a parallel atomic, even though there's some duplication that way.
jmarantz commentedon Jan 11, 2021
I thought of another option, which would be a lot of toil to implement, but might be easier to maintain: to disallow reading the
value()of a stat from production code.There are a few hurdles to doing this:
value()from stats in production, such as in the implementation of stats sinks and the admin console, where it's expected behavior for those to just return 0 if the stats were disallowedvalue().There are a few possible solutions to dealing with this that involve changing a lot of code. The first I thought of is:
value()beprotectedin the stats classes, and usefriendto allow admin/stats-sink accessvalueForTestto counters/gauges/text-readout which ispublic, but use lint to avoid calling that from production codeThis is a bit of toil because it involves changing a huge number of lines of unit tests, and that. will may make future backports fail, adding further toil. But maybe that's the best long term solution.
A variant on that is to use a testing peer class for looking at stats in tests, rather than having a specially-named method. That avoids relying on lint, but involves slightly more toil in doing the conversion.
mattklein123 commentedon Jan 11, 2021
So I agree ^ is probably the correct solution, as it would actually fix the problem for real versus still having to play whack a mole all the time. I'm not sure if it's worth the effort vs. just fixing issues as the come up.
WDYT?
jmarantz commentedon Jan 19, 2021
See discussion in doc: https://docs.google.com/document/d/1CnyeIi5hMBqXZRKm-0_yW3yy69HM80BHg-EGwkJb-qw/edit
jmarantz commentedon Sep 10, 2021
@yanavlasov FYI -- this would be a good candidate for someone to build up some clang skills with.
Stats: Filter stats to be flushed to sinks (#18805)
jmarantz commentedon Apr 28, 2022
@krajshiva FYI -- this was the bug I was talking about where we might be able to save a lot of toil if we build some clang skills.
jmarantz commentedon Mar 4, 2023
@stevenzzzz note that #23921 adds a new instance of the anti-pattern of reading a stat value from production.