You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by "abstractdog (via GitHub)" <gi...@apache.org> on 2026/09/10 09:27:57 UTC

[PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

abstractdog opened a new pull request, #6773:
URL: https://github.com/apache/hive/pull/6773

   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://cwiki.apache.org/confluence/display/Hive/HowToContribute
     2. Ensure that you have created an issue on the Hive project JIRA: https://issues.apache.org/jira/projects/HIVE/summary
     3. Ensure you have added or run the appropriate tests for your PR: 
     4. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP]HIVE-XXXXX:  Your PR title ...'.
     5. Be sure to keep the PR description updated to reflect all changes.
     6. Please write your PR title to summarize what this PR proposes.
     7. If possible, provide a concise example to reproduce the issue for a faster review.
   
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If you fix some SQL features, you can provide some references of other DBMSes.
     3. If there is design documentation, please add the link.
     4. If there is a discussion in the mailing list, please add the link.
   -->
   
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   
   ### Does this PR introduce _any_ user-facing change?
   <!--
   Note that it means *any* user-facing change including all aspects such as the documentation fix.
   If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description, screenshot and/or a reproducible example to show the behavior difference if possible.
   If possible, please also clarify if this is a user-facing change compared to the released Hive versions or within the unreleased branches such as master.
   If no, write 'No'.
   -->
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   


-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6773:
URL: https://github.com/apache/hive/pull/6773#issuecomment-5621111191

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6773) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [1 New issue](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6773&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6773&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6773&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6773&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6773&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6773)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4062545190


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/util/Workloads.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hive.kubernetes.operator.util;
+
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.fabric8.kubernetes.api.model.apps.StatefulSet;
+import org.apache.hive.kubernetes.operator.model.HiveCluster;
+
+/**
+ * Helpers for the operator's workloads (Deployment/StatefulSet): reading fields without the
+ * null-guard boilerplate every caller would otherwise repeat, and resolving the workload's
+ * K8s name from the autoscaler's component key.
+ */
+public final class Workloads {
+
+  private Workloads() {}
+
+  /**
+   * Returns spec.replicas from a Deployment or StatefulSet, or null when the resource is
+   * absent, has no spec, or the field is unset. A non-workload resource returns null too.
+   */
+  public static Integer replicas(HasMetadata resource) {

Review Comment:
   `Workloads.replicas` now returns `OptionalInt`



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6773:
URL: https://github.com/apache/hive/pull/6773#issuecomment-5778095537

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6773) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [3 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6773&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6773&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6773&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6773&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [2.9% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6773&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6773)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036867066


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/reconciler/HiveClusterReconciler.java:
##########
@@ -577,6 +567,30 @@ private void patchReplicas(KubernetesClient client, HiveCluster resource,
     }
   }
 
+  /**
+   * Emits an INFO log when the reconciler's server-side apply is about to change the workload's
+   * replica count. Without this, an SSA-driven scale (a user editing spec.llapClusters[i].replicas,
+   * a helm upgrade rewriting it) reaches the StatefulSet/Deployment silently -- only the
+   * autoscaler path {@link #patchReplicas} logged its scales, so a plain scale looked like the
+   * operator was doing nothing. Read failures are swallowed at DEBUG: the SSA below runs either
+   * way, and a missing pre-scale line is not worth failing the reconcile over.
+   */
+  private void logReplicaChange(KubernetesClient client, String ns, String workloadName,

Review Comment:
   can we generalize log method or need both?



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036785093


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -186,21 +195,37 @@ protected Integer resolveReplicaCount(P primary, Context<P> context,
         return managed;
       }
       // Fallback: operator restarted and MANAGED_REPLICAS is empty — read current value
-      R resource = existing.get();
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.Deployment d) {
-        return d.getSpec() != null && d.getSpec().getReplicas() != null
-            ? d.getSpec().getReplicas() : initialReplicas;
-      }
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.StatefulSet s) {
-        return s.getSpec() != null && s.getSpec().getReplicas() != null
-            ? s.getSpec().getReplicas() : initialReplicas;
-      }
-      return initialReplicas;
+      Integer current = Workloads.replicas(existing.get());
+      return current != null ? current : initialReplicas;
     }
     // First creation: start at minReplicas.
     return initialReplicas;
   }
 
+  /**
+   * Emits an INFO line when the SSA about to run will actually change the workload's replica
+   * count. Silence means the count already matches, so no scale is happening. Without this,
+   * every scale of an HS2/Metastore Deployment reached the cluster silently (only the imperative
+   * LLAP path and the autoscaler logged); a bare "Reconciled" line said nothing about the size.
+   * Uses the same "Scaling ... A -> B" shape the imperative LLAP path emits.
+   */
+  private void logReplicaChange(P primary, Optional<R> existing, Integer desired) {
+    String component = getComponentName();
+    if (component == null || desired == null) {
+      return;
+    }
+    String ns = primary.getMetadata().getNamespace();
+    String name = existing.map(r -> r.getMetadata().getName()).orElse(component);
+    if (existing.isEmpty()) {
+      LOG.info("Creating {} {}/{} with {} replicas", component, ns, name, desired);
+      return;
+    }
+    Integer current = Workloads.replicas(existing.get());
+    if (current != null && !current.equals(desired)) {
+      LOG.info("Scaling {} {}/{}: {} -> {} replicas", component, ns, name, current, desired);

Review Comment:
   Maybe "Setting replica count for {} to {}?"



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036820430


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -186,21 +195,37 @@ protected Integer resolveReplicaCount(P primary, Context<P> context,
         return managed;
       }
       // Fallback: operator restarted and MANAGED_REPLICAS is empty — read current value
-      R resource = existing.get();
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.Deployment d) {
-        return d.getSpec() != null && d.getSpec().getReplicas() != null
-            ? d.getSpec().getReplicas() : initialReplicas;
-      }
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.StatefulSet s) {
-        return s.getSpec() != null && s.getSpec().getReplicas() != null
-            ? s.getSpec().getReplicas() : initialReplicas;
-      }
-      return initialReplicas;
+      Integer current = Workloads.replicas(existing.get());
+      return current != null ? current : initialReplicas;
     }
     // First creation: start at minReplicas.
     return initialReplicas;
   }
 
+  /**
+   * Emits an INFO line when the SSA about to run will actually change the workload's replica
+   * count. Silence means the count already matches, so no scale is happening. Without this,
+   * every scale of an HS2/Metastore Deployment reached the cluster silently (only the imperative
+   * LLAP path and the autoscaler logged); a bare "Reconciled" line said nothing about the size.
+   * Uses the same "Scaling ... A -> B" shape the imperative LLAP path emits.
+   */
+  private void logReplicaChange(P primary, Optional<R> existing, Integer desired) {
+    String component = getComponentName();
+    if (component == null || desired == null) {

Review Comment:
   can the component be null?



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036816231


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -186,21 +195,37 @@ protected Integer resolveReplicaCount(P primary, Context<P> context,
         return managed;
       }
       // Fallback: operator restarted and MANAGED_REPLICAS is empty — read current value
-      R resource = existing.get();
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.Deployment d) {
-        return d.getSpec() != null && d.getSpec().getReplicas() != null
-            ? d.getSpec().getReplicas() : initialReplicas;
-      }
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.StatefulSet s) {
-        return s.getSpec() != null && s.getSpec().getReplicas() != null
-            ? s.getSpec().getReplicas() : initialReplicas;
-      }
-      return initialReplicas;
+      Integer current = Workloads.replicas(existing.get());

Review Comment:
   can the current be null if existing.isPresent()?



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #6773:
URL: https://github.com/apache/hive/pull/6773#issuecomment-5700137182

   ## [![Quality Gate Passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/qg-passed-20px.png 'Quality Gate Passed')](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6773) **Quality Gate passed**  
   Issues  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 New issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6773&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/accepted-16px.png '') [0 Accepted issues](https://sonarcloud.io/project/issues?id=apache_hive&pullRequest=6773&issueStatuses=ACCEPTED)
   
   Measures  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_hive&pullRequest=6773&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Coverage on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6773&metric=new_coverage&view=list)  
   ![](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/passed-16px.png '') [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=apache_hive&pullRequest=6773&metric=new_duplicated_lines_density&view=list)  
     
   <!-- sqra-placement-anchor -->
   [See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=apache_hive&pullRequest=6773)
   
   


-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4062518725


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -186,21 +195,37 @@ protected Integer resolveReplicaCount(P primary, Context<P> context,
         return managed;
       }
       // Fallback: operator restarted and MANAGED_REPLICAS is empty — read current value
-      R resource = existing.get();
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.Deployment d) {
-        return d.getSpec() != null && d.getSpec().getReplicas() != null
-            ? d.getSpec().getReplicas() : initialReplicas;
-      }
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.StatefulSet s) {
-        return s.getSpec() != null && s.getSpec().getReplicas() != null
-            ? s.getSpec().getReplicas() : initialReplicas;
-      }
-      return initialReplicas;
+      Integer current = Workloads.replicas(existing.get());
+      return current != null ? current : initialReplicas;
     }
     // First creation: start at minReplicas.
     return initialReplicas;
   }
 
+  /**
+   * Emits an INFO line when the SSA about to run will actually change the workload's replica
+   * count. Silence means the count already matches, so no scale is happening. Without this,
+   * every scale of an HS2/Metastore Deployment reached the cluster silently (only the imperative
+   * LLAP path and the autoscaler logged); a bare "Reconciled" line said nothing about the size.
+   * Uses the same "Scaling ... A -> B" shape the imperative LLAP path emits.
+   */
+  private void logReplicaChange(P primary, Optional<R> existing, Integer desired) {
+    String component = getComponentName();
+    if (component == null || desired == null) {

Review Comment:
   no, only `HiveServer2DeploymentDependent` and `MetastoreDeploymentDependent` call
   `resolveReplicaCount`, and both override getComponentName()
   dropped the guard



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4062500115


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -186,21 +195,37 @@ protected Integer resolveReplicaCount(P primary, Context<P> context,
         return managed;
       }
       // Fallback: operator restarted and MANAGED_REPLICAS is empty — read current value
-      R resource = existing.get();
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.Deployment d) {
-        return d.getSpec() != null && d.getSpec().getReplicas() != null
-            ? d.getSpec().getReplicas() : initialReplicas;
-      }
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.StatefulSet s) {
-        return s.getSpec() != null && s.getSpec().getReplicas() != null
-            ? s.getSpec().getReplicas() : initialReplicas;
-      }
-      return initialReplicas;
+      Integer current = Workloads.replicas(existing.get());

Review Comment:
   in practice no, the API server defaults spec.replicas on write; documented that in both the javadoc and the fallback comment. orElse(initialReplicas) now expresses it as a floor rather than a null check



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036795365


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -164,6 +165,15 @@ protected R handleCreate(R desired, P primary, Context<P> context) {
    */
   protected Integer resolveReplicaCount(P primary, Context<P> context,
       AutoscalingSpec autoscaling, int staticReplicas, int initialReplicas) {
+    Optional<R> existing = getSecondaryResource(primary, context);
+    Integer resolved = computeReplicaCount(primary, existing, autoscaling,
+        staticReplicas, initialReplicas);
+    logReplicaChange(primary, existing, resolved);

Review Comment:
   do we log even when existing is empty? log on boostrap, first creation ?



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4062541184


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/reconciler/HiveClusterReconciler.java:
##########
@@ -577,6 +567,30 @@ private void patchReplicas(KubernetesClient client, HiveCluster resource,
     }
   }
 
+  /**
+   * Emits an INFO log when the reconciler's server-side apply is about to change the workload's
+   * replica count. Without this, an SSA-driven scale (a user editing spec.llapClusters[i].replicas,
+   * a helm upgrade rewriting it) reaches the StatefulSet/Deployment silently -- only the
+   * autoscaler path {@link #patchReplicas} logged its scales, so a plain scale looked like the
+   * operator was doing nothing. Read failures are swallowed at DEBUG: the SSA below runs either
+   * way, and a missing pre-scale line is not worth failing the reconcile over.
+   */
+  private void logReplicaChange(KubernetesClient client, String ns, String workloadName,

Review Comment:
   both `logReplicaChange` implementations collapsed into `Workloads.logReplicaChange`
   the reconciler keeps only a few lines wrapper that does the API-server read and passes the resource in



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

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


-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4062417451


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/LlapResourceBuilder.java:
##########
@@ -208,17 +208,22 @@ public static PodDisruptionBudget buildPdb(HiveCluster hc, LlapSpec llap) {
 
   /** TezAM Deployment/Service name for a specific LLAP cluster. */

Review Comment:
   LlapResourceBuilder.buildTezAmDeployment returns a Deployment, and LLAP is already a StatefulSet 



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4062442857


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -186,21 +195,37 @@ protected Integer resolveReplicaCount(P primary, Context<P> context,
         return managed;
       }
       // Fallback: operator restarted and MANAGED_REPLICAS is empty — read current value
-      R resource = existing.get();
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.Deployment d) {
-        return d.getSpec() != null && d.getSpec().getReplicas() != null
-            ? d.getSpec().getReplicas() : initialReplicas;
-      }
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.StatefulSet s) {
-        return s.getSpec() != null && s.getSpec().getReplicas() != null
-            ? s.getSpec().getReplicas() : initialReplicas;
-      }
-      return initialReplicas;
+      Integer current = Workloads.replicas(existing.get());
+      return current != null ? current : initialReplicas;
     }
     // First creation: start at minReplicas.
     return initialReplicas;
   }
 
+  /**
+   * Emits an INFO line when the SSA about to run will actually change the workload's replica
+   * count. Silence means the count already matches, so no scale is happening. Without this,
+   * every scale of an HS2/Metastore Deployment reached the cluster silently (only the imperative
+   * LLAP path and the autoscaler logged); a bare "Reconciled" line said nothing about the size.
+   * Uses the same "Scaling ... A -> B" shape the imperative LLAP path emits.
+   */
+  private void logReplicaChange(P primary, Optional<R> existing, Integer desired) {
+    String component = getComponentName();
+    if (component == null || desired == null) {
+      return;
+    }
+    String ns = primary.getMetadata().getNamespace();
+    String name = existing.map(r -> r.getMetadata().getName()).orElse(component);
+    if (existing.isEmpty()) {
+      LOG.info("Creating {} {}/{} with {} replicas", component, ns, name, desired);
+      return;
+    }
+    Integer current = Workloads.replicas(existing.get());
+    if (current != null && !current.equals(desired)) {
+      LOG.info("Scaling {} {}/{}: {} -> {} replicas", component, ns, name, current, desired);

Review Comment:
   merged them to one shared `Workloads.logReplicaChange` with a single message



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036785093


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -186,21 +195,37 @@ protected Integer resolveReplicaCount(P primary, Context<P> context,
         return managed;
       }
       // Fallback: operator restarted and MANAGED_REPLICAS is empty — read current value
-      R resource = existing.get();
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.Deployment d) {
-        return d.getSpec() != null && d.getSpec().getReplicas() != null
-            ? d.getSpec().getReplicas() : initialReplicas;
-      }
-      if (resource instanceof io.fabric8.kubernetes.api.model.apps.StatefulSet s) {
-        return s.getSpec() != null && s.getSpec().getReplicas() != null
-            ? s.getSpec().getReplicas() : initialReplicas;
-      }
-      return initialReplicas;
+      Integer current = Workloads.replicas(existing.get());
+      return current != null ? current : initialReplicas;
     }
     // First creation: start at minReplicas.
     return initialReplicas;
   }
 
+  /**
+   * Emits an INFO line when the SSA about to run will actually change the workload's replica
+   * count. Silence means the count already matches, so no scale is happening. Without this,
+   * every scale of an HS2/Metastore Deployment reached the cluster silently (only the imperative
+   * LLAP path and the autoscaler logged); a bare "Reconciled" line said nothing about the size.
+   * Uses the same "Scaling ... A -> B" shape the imperative LLAP path emits.
+   */
+  private void logReplicaChange(P primary, Optional<R> existing, Integer desired) {
+    String component = getComponentName();
+    if (component == null || desired == null) {
+      return;
+    }
+    String ns = primary.getMetadata().getNamespace();
+    String name = existing.map(r -> r.getMetadata().getName()).orElse(component);
+    if (existing.isEmpty()) {
+      LOG.info("Creating {} {}/{} with {} replicas", component, ns, name, desired);
+      return;
+    }
+    Integer current = Workloads.replicas(existing.get());
+    if (current != null && !current.equals(desired)) {
+      LOG.info("Scaling {} {}/{}: {} -> {} replicas", component, ns, name, current, desired);

Review Comment:
   Maybe "Setting replica count for {} to {}?" maybe we can join both crate and scale ?



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036850298


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/LlapResourceBuilder.java:
##########
@@ -208,17 +208,22 @@ public static PodDisruptionBudget buildPdb(HiveCluster hc, LlapSpec llap) {
 
   /** TezAM Deployment/Service name for a specific LLAP cluster. */

Review Comment:
   For TezAM we have statefullset, not deployment, no? That actually makes me wonder why we have deployment for LLAP that doesn't allow parallel botstrap and rolling upgrade is sequential



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036795365


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -164,6 +165,15 @@ protected R handleCreate(R desired, P primary, Context<P> context) {
    */
   protected Integer resolveReplicaCount(P primary, Context<P> context,
       AutoscalingSpec autoscaling, int staticReplicas, int initialReplicas) {
+    Optional<R> existing = getSecondaryResource(primary, context);
+    Integer resolved = computeReplicaCount(primary, existing, autoscaling,
+        staticReplicas, initialReplicas);
+    logReplicaChange(primary, existing, resolved);

Review Comment:
   do we log even when existing is empty?



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4062463762


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/dependent/HiveDependentResource.java:
##########
@@ -164,6 +165,15 @@ protected R handleCreate(R desired, P primary, Context<P> context) {
    */
   protected Integer resolveReplicaCount(P primary, Context<P> context,
       AutoscalingSpec autoscaling, int staticReplicas, int initialReplicas) {
+    Optional<R> existing = getSecondaryResource(primary, context);
+    Integer resolved = computeReplicaCount(primary, existing, autoscaling,
+        staticReplicas, initialReplicas);
+    logReplicaChange(primary, existing, resolved);

Review Comment:
   handled in `Workloads.logReplicaChange`, first creation is shown as `none -> ...`



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "deniskuzZ (via GitHub)" <gi...@apache.org>.
deniskuzZ commented on code in PR #6773:
URL: https://github.com/apache/hive/pull/6773#discussion_r4036882408


##########
packaging/src/kubernetes/src/java/org/apache/hive/kubernetes/operator/util/Workloads.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.hive.kubernetes.operator.util;
+
+import io.fabric8.kubernetes.api.model.HasMetadata;
+import io.fabric8.kubernetes.api.model.apps.Deployment;
+import io.fabric8.kubernetes.api.model.apps.StatefulSet;
+import org.apache.hive.kubernetes.operator.model.HiveCluster;
+
+/**
+ * Helpers for the operator's workloads (Deployment/StatefulSet): reading fields without the
+ * null-guard boilerplate every caller would otherwise repeat, and resolving the workload's
+ * K8s name from the autoscaler's component key.
+ */
+public final class Workloads {
+
+  private Workloads() {}
+
+  /**
+   * Returns spec.replicas from a Deployment or StatefulSet, or null when the resource is
+   * absent, has no spec, or the field is unset. A non-workload resource returns null too.
+   */
+  public static Integer replicas(HasMetadata resource) {

Review Comment:
   iDK, should it be optional? replicas can't be null unless deployment/sts not running



-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


Re: [PR] HIVE-30033: Hive K8s operator: log replica changes [hive]

Posted by "abstractdog (via GitHub)" <gi...@apache.org>.
abstractdog commented on PR #6773:
URL: https://github.com/apache/hive/pull/6773#issuecomment-5772199467

   operator logs with the latest change when starting a cluster:
   
   ```
   2026-09-22T06:29:38,371 INFO  [pool-8-thread-30[] HiveDependentResource: Setting replica count for metastore lbodor-perf/hive-metastore: 0 -> 1
   2026-09-22T06:29:38,396 INFO  [ReconcilerExecutor-hiveclusterreconciler-66[] HiveClusterReconciler: Cluster lbodor-perf/hive woken up
   2026-09-22T06:29:38,417 INFO  [ReconcilerExecutor-hiveclusterreconciler-66[] HiveClusterReconciler: Setting replica count for llap lbodor-perf/hive-llap0: 0 -> 1
   2026-09-22T06:29:38,454 INFO  [ReconcilerExecutor-hiveclusterreconciler-66[] HiveClusterReconciler: Setting replica count for tezam lbodor-perf/hive-tezam-llap0: 0 -> 1
   2026-09-22T06:31:39,028 INFO  [pool-8-thread-46[] HiveDependentResource: Setting replica count for hiveserver2 lbodor-perf/hive-hiveserver2: none -> 1
   ```


-- 
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: gitbox-unsubscribe@hive.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org