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

Dynamically switch jmx/sensor names based on dual read mode and source type #926

Merged
merged 4 commits into from
Aug 15, 2023

Conversation

bohhyang
Copy link
Contributor

@bohhyang bohhyang commented Jul 28, 2023

Background

Currently Jmx/sensors (load balancer, load balancer state, file stores, clusterInfo, serviceProperties, LoadBalancerStrategy, etc) are having the same name in ZK and xDS read flow. The current code intended to give D2ClientJmxManager.java a different prefix in xDS flow ("-xDS"), which had a bug in container and wasn't working. Even if worked, it would still break the jmx/sensors because depending on the dynamically changing dual read mode value, the primary source (ZK in OLD_LB_ONLY and DUAL_READ modes; xDS in NEW_LB_ONLY mode) should register the jmx/sensor names same as today, so that users can still monitor the same metrics. And, the secondary source should register different names to avoid conflicting with the primary.

Changes

  1. added watchers to dual read mode and dynamically register jmx/sensor names for primary/secondary sources under the new dual read mode.
  2. Include the source type name ("-xDS", "-ZK") in the secondary source's jmx/sensor names.
  3. bumped major version. Will create a container PR to include this change to container. Since the previous 29.43.xxx versions will have broken Jmx/sensor names if switched to observer-only read mode, I'll deprecate those versions once this is released.

Test Done

  1. added unit tests for add/remove watchers and registering jmx/sensor names.
  2. QEI deployment with Toki and switch dual read modes with lix:
    Under dual read or zk-only modes, the ZK source is primary, and xDS source registered the names with "-xDS":
    Screenshot 2023-08-02 at 5 24 03 PM

Under observer-only mode, app log shows the primary names are unregistered and re-registered (done by xDS source), and the "-ZK" names are registered (by ZK source):
Screenshot 2023-08-06 at 4 58 19 PM
, and the jmx/sensor names also show the same:
Screenshot 2023-08-06 at 5 25 08 PM

Note: the "-xDS" names are left there (not unregistered), since they won't hurt during the dual read testing and will be cleaned when the app adopts xDS load balancer (by config, so dual read load balancer is not used at all) and redeploys.

@bohhyang bohhyang force-pushed the bohan/fixLBMetricsForDualReadAndIndisOnly branch from 7c3074f to 828b52a Compare July 28, 2023 18:45
@bohhyang bohhyang force-pushed the bohan/fixLBMetricsForDualReadAndIndisOnly branch from 828b52a to e8b922c Compare August 6, 2023 21:54
@bohhyang bohhyang changed the title Differentiate LB metrics between ZK and xDS read flows Dynamically switch jmx/sensor names based on dual read mode and source type Aug 6, 2023
Comment on lines -44 to -45
@Mock
JmxManager _jmxManager;
Copy link
Contributor Author

@bohhyang bohhyang Aug 6, 2023

Choose a reason for hiding this comment

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

I've put these mocks into a fixture because direct mock member vars inside the class can't be used in a data provider. For example, when I create different D2ClientJmxManager with different params but use the same _jmxManager mock:

@DataProvider
public Object[][] dataProvider()
{
   return new Object[][]
   {
      {new D2ClientJmxManager(..., _jmxManager)}
      {new D2ClientJmxManager(..., _jmxManager, ...ZK, null)}
      {new D2ClientJmxManager(..., _jmxManager, ....xDS, null)}
   };
}

Using this data provider in a test method (such as testSetSimpleLBStateListenerUpdateClusterInfo), the test will fail with errors saying the mock is null.

Copy link
Member

Choose a reason for hiding this comment

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

Seems fine by me, it's easier to pass in one object than 10 !

@bohhyang
Copy link
Contributor Author

bohhyang commented Aug 7, 2023

discussed with @PapaCharlie over slack, it's better to separate out the watchers for different property types into separate maps or member vars, so it's less error-prone for future devs to add watchers for new types of properties. I did so and also moved the watcher management logic to a separate manager class for cleanlyness.

@bohhyang bohhyang merged commit 641694b into master Aug 15, 2023
1 check passed
@bohhyang bohhyang deleted the bohan/fixLBMetricsForDualReadAndIndisOnly branch August 15, 2023 22:45
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.

5 participants