gnodet commented on code in PR #22282:
URL: https://github.com/apache/camel/pull/22282#discussion_r2995124241


##########
components/camel-pqc/src/main/java/org/apache/camel/component/pqc/PQCStatefulKeyHealthCheck.java:
##########
@@ -78,24 +65,35 @@ protected void doCall(HealthCheckResultBuilder builder, 
Map<String, Object> opti
             return;
         }
 
+        long totalCapacity = index + remaining;
+
         builder.detail("stateful_key", true);
         builder.detail("algorithm", algorithm);
         builder.detail("remaining_signatures", remaining);
         builder.detail("signatures_used", index);
-        builder.detail("total_capacity", index + remaining);
+        builder.detail("total_capacity", totalCapacity);
 
-        if (remaining <= 0) {
+        if (remaining == 0) {
             builder.message("Stateful key (" + algorithm + ") is exhausted 
with 0 remaining signatures");
             builder.down();
             return;
         }
 
-        double threshold = configuration.getStatefulKeyWarningThreshold();
-        long totalCapacity = index + remaining;
+        double threshold = 
endpoint.getConfiguration().getStatefulKeyWarningThreshold();
         if (threshold > 0 && totalCapacity > 0) {
             double fractionRemaining = (double) remaining / totalCapacity;
             builder.detail("fraction_remaining", String.format("%.4f", 
fractionRemaining));
             builder.detail("warning_threshold", String.valueOf(threshold));
+
+            if (fractionRemaining <= threshold) {
+                builder.message(
+                        "Stateful key (" + algorithm + ") is approaching 
exhaustion: " + remaining
+                                + " signatures remaining out of " + 
totalCapacity + " total ("
+                                + String.format("%.1f%%", fractionRemaining * 
100) + " remaining)");
+                builder.detail("warning", true);
+                builder.down();
+                return;

Review Comment:
   Camel's `HealthCheck.State` has no `DEGRADED` — only `UP`, `DOWN`, 
`UNKNOWN`. Using `DOWN` here treats a key with remaining capacity the same as 
an exhausted key for readiness probes.
   
   Remove both `builder.down()` and `return` so the method falls through to 
`builder.up()` on line 99. The warning message and detail are still set for 
operators to alert on. (Keeping `return` without `builder.down()` would exit 
with no state set.)
   
   ```suggestion
                   // Stay UP — the key still has capacity. Operators can alert 
on the "warning" detail.
   ```



-- 
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