imDwAaY opened a new issue, #7965:
URL: https://github.com/apache/shenyu/issues/7965

   ## Current behavior
   
   Policy 3 (metric-driven scaling) is wired end to end except for one missing 
link: nothing ever registers an observer.
   
   `MetricsMonitor.monitorMetrics()` loads enabled `ScaleRuleDO` rows, fetches 
each metric through `PrometheusMetricsProvider`, and calls 
`notifyObservers(...)`. But the observer list is populated only through 
`MetricsMonitor.addObserver(...)`, which has no caller in the repository, and 
`ScaleObserver` is never instantiated in production code.
   
   Evidence on `master`:
   - Searching for `addObserver` returns only the `Subject` interface and 
`MetricsMonitor` implementations.
   - Searching for `new ScaleObserver` returns no production call site; 
`ScaleObserver` is not annotated with `@Component`.
   - `ScaleRuleEvaluator` is a `@Component`, but its only reference is the 
`ScaleObserver` constructor.
   
   Consequently `observers` is always empty. A rule whose metric exceeds 
`maximum` or falls below `minimum` never produces a `ScaleAction`, and 
`KubernetesScaler.scaleByAction` is never called on the metric-driven path.
   
   ## Location
   
   - 
`shenyu-admin/src/main/java/org/apache/shenyu/admin/scale/monitor/subject/MetricsMonitor.java`
   - 
`shenyu-admin/src/main/java/org/apache/shenyu/admin/scale/monitor/observer/ScaleObserver.java`
   - 
`shenyu-admin/src/main/java/org/apache/shenyu/admin/scale/scaler/ScaleService.java`
 (`startDynamicTask` schedules `monitorMetrics`)
   
   ## Expected behavior
   
   When policy 3 is active, one metric evaluation above `maximum` must produce 
exactly one scale-up action, and one below `minimum` exactly one scale-down 
action.
   
   ## Suggested fix
   
   Register a `ScaleObserver` with `MetricsMonitor` at wiring time — for 
example make `ScaleObserver` a Spring component and inject the `Observer` beans 
into `MetricsMonitor`, or register it from the scaling lifecycle. Add a 
regression test that runs `monitorMetrics()` with a rule and a metric above the 
threshold and verifies `KubernetesScaler.scaleByAction` is invoked once.
   
   Related: #7913 decides which Admin replica is allowed to drive scaling; this 
issue is about the actuator never being connected in the first place.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to