You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ambari.apache.org by "almeidajeff (via GitHub)" <gi...@apache.org> on 2026/09/18 14:40:52 UTC

[PR] AMBARI-26661. Refresh telemetry assignments on component state transi… [ambari]

almeidajeff opened a new pull request, #4222:
URL: https://github.com/apache/ambari/pull/4222

   ## What changes were proposed in this pull request?
   
   On a freshly installed cluster, VMAGENT never receives component scrape targets for
   HDFS/YARN/HBase. The per-host telemetry assignment stays empty until something unrelated
   forces a recompile — a cluster config change, or an ambari-server restart.
   
   Root cause, following the chain:
   
   1. `ServiceComponentHostImpl` publishes `ServiceComponentInstalledEvent` from its constructor,
      right after persisting the host component row with desired state `INIT`.
   2. `TelemetryHolder` subscribes to that event as its only per-component hook.
   3. `TelemetryAssignmentCompiler.compileCluster()` skips any component that is not in an
      installed state, and `isInstalled()` accepts only `INSTALLED`, `STARTING`, `STARTED`,
      `STOPPING`, `UPGRADING`, `DISABLED` and `UNKNOWN` — `INIT` is not among them.
   4. `handleEvent()`, which processes the real state transitions, refreshes
      `HostLevelParamsHolder` but never `TelemetryHolder`.
   
   So the only assignment ever compiled for a host is the one built at `INIT`, which by
   definition contains no component targets, and nothing revisits it on the normal
   install/start path.
   
   Changes:
   
   - `ServiceComponentHostImpl` now refreshes `TelemetryHolder` inside `handleEvent()`, in the
     same block that already publishes `HostComponentsUpdateEvent` on a real status change.
   - `TelemetryHolder.getCurrentData(Long)` is widened from `protected` to `public` so it is
     callable from there, matching how `HostLevelParamsHolder` already exposes it.
   
   ## How was this patch tested?
   
   Two new tests, both run on trunk with this patch applied:
   
   - **`TelemetryAssignmentCompilerTest.testTargetsAppearOnlyAfterComponentLeavesInitState`** —
     asserts a component in `INIT` contributes no targets while `INSTALLED` and `STARTED` each
     contribute one. This documents why subscribing to `ServiceComponentInstalledEvent` cannot
     work, independently of the fix.
   - **`ServiceComponentHostTest.testTelemetryIsRefreshedOnComponentStateTransition`** — asserts
     that a real state transition repopulates the host's telemetry assignment. The cached
     assignment is dropped after `createEvent()` rather than before, because creating a config
     publishes `ClusterConfigChangedEvent`, which `TelemetryHolder` also refreshes on — the very
     mechanism that masks this bug on a real cluster.
   
   ```
   $ mvn -pl ambari-server surefire:test \
       -Dtest='TelemetryAssignmentCompilerTest,ServiceComponentHostTest#testTelemetryIsRefreshedOnComponentStateTransition'
   
   [INFO]  T E S T S
   [INFO] Running org.apache.ambari.server.agent.stomp.TelemetryAssignmentCompilerTest
   [INFO] Running org.apache.ambari.server.state.svccomphost.ServiceComponentHostTest
   [INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.590 s -- in org.apache.ambari.server.agent.stomp.TelemetryAssignmentCompilerTest
   [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 21.39 s -- in org.apache.ambari.server.state.svccomphost.ServiceComponentHostTest
   [INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
   [INFO] BUILD SUCCESS
   ```
   
   The second test was verified to be a genuine regression test: with the
   `TelemetryHolder` refresh in `handleEvent()` reverted, it fails as expected.
   
   ```
   [ERROR] ServiceComponentHostTest.testTelemetryIsRefreshedOnComponentStateTransition:576
           A real state transition must refresh the host's telemetry assignment
   [ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
   [INFO] BUILD FAILURE
   ```
   
   Not covered by automated tests: the end-to-end behaviour on a live cluster (installing
   VICTORIAMETRICS alongside HDFS/YARN/HBase and confirming VMAGENT receives component scrape
   targets with no unrelated config change).
   
   
   
   <img width="2090" height="971" alt="image" src="https://github.com/user-attachments/assets/12e4f09c-9a96-415e-86a9-d13b517da2cc" />
   
   <img width="2089" height="967" alt="image" src="https://github.com/user-attachments/assets/c0e30106-78fe-4460-b3f4-1bfc02dcd66d" />
   
   <img width="2081" height="932" alt="image" src="https://github.com/user-attachments/assets/dc2b73e8-4994-463c-a4fc-9c873064d927" />
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ambari.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ambari.apache.org
For additional commands, e-mail: dev-help@ambari.apache.org


Re: [PR] AMBARI-26661. Refresh telemetry assignments on component state transi… [ambari]

Posted by "JiaLiangC (via GitHub)" <gi...@apache.org>.
JiaLiangC merged PR #4222:
URL: https://github.com/apache/ambari/pull/4222


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@ambari.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ambari.apache.org
For additional commands, e-mail: dev-help@ambari.apache.org