ayushtkn commented on code in PR #6507:
URL: https://github.com/apache/hive/pull/6507#discussion_r3427970045


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -422,4 +633,233 @@ protected static Probe buildTcpProbe(int port, ProbeSpec 
spec, int defaultInitia
     return builder.build();
   }
 
+  /**
+   * Applies the autoscaling lifecycle to a workload's pod template: sets a 
preStop
+   * exec lifecycle hook, terminationGracePeriodSeconds, and Prometheus scrape 
annotations.
+   *
+   * @param podSpec           the pod spec of the workload (Deployment or 
StatefulSet)
+   * @param podMetadata       the pod template metadata (for annotations)
+   * @param preStopScript     the shell script to run in the preStop hook
+   * @param gracePeriodSeconds termination grace period
+   */
+  protected static void applyAutoscalingLifecycle(
+      io.fabric8.kubernetes.api.model.PodSpec podSpec,
+      io.fabric8.kubernetes.api.model.ObjectMeta podMetadata,
+      String preStopScript, int gracePeriodSeconds,
+      int metricsScrapeIntervalSeconds) {
+    io.fabric8.kubernetes.api.model.Lifecycle lifecycle =
+        new io.fabric8.kubernetes.api.model.LifecycleBuilder()
+            .withNewPreStop()
+              .withNewExec()
+                .withCommand("/bin/bash", "-c", preStopScript)
+              .endExec()
+            .endPreStop()
+            .build();
+    podSpec.getContainers().get(0).setLifecycle(lifecycle);
+    podSpec.setTerminationGracePeriodSeconds((long) gracePeriodSeconds);
+    applyPrometheusScrapeAnnotations(podMetadata, 
metricsScrapeIntervalSeconds);
+  }
+
+  /**
+   * Adds Prometheus scrape annotations to a pod template so that
+   * the JMX Exporter metrics endpoint is discovered by Prometheus.
+   */
+  private static void applyPrometheusScrapeAnnotations(
+      io.fabric8.kubernetes.api.model.ObjectMeta podMetadata,
+      int scrapeIntervalSeconds) {
+    podMetadata.getAnnotations().put("prometheus.io/scrape", "true");
+    podMetadata.getAnnotations().put("prometheus.io/port",
+        String.valueOf(ConfigUtils.PROMETHEUS_JMX_EXPORTER_PORT));
+    podMetadata.getAnnotations().put("prometheus.io/path", "/metrics");
+    podMetadata.getAnnotations().put("prometheus.io/scrape-interval",
+        scrapeIntervalSeconds + "s");
+  }

Review Comment:
   @aturoczy I already sorted it, some UI issue that it doesn't show outdated 
in Github
   
https://github.com/apache/hive/pull/6507/changes#diff-c6a162031045bc7cf7f01658514cca5c5d2e690c5397a229e0ef45d2ae4bb71dR671-R673
   But co-pilot recogonises this is outdated
   <img width="769" height="164" alt="image" 
src="https://github.com/user-attachments/assets/d4a52d1f-5846-446d-a648-502b5aa748fc";
 />
   



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to