Skip to content

HIVE-30033: Hive K8s operator: log replica changes - #6773

Open
abstractdog wants to merge 2 commits into
apache:masterfrom
abstractdog:HIVE-30033
Open

abstractdog wants to merge 2 commits into
apache:masterfrom
abstractdog:HIVE-30033

Conversation

@abstractdog

@abstractdog abstractdog commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Log an INFO line in the reconciler whenever a HiveCluster component is created or scaled to a different replica count. Covers LLAP, TezAM, HiveServer2 and Metastore.

Why are the changes needed?

Scales driven by an SSA on the CR (helm upgrade, kubectl edit, a tool changing .spec.*.replicas) reached the workload silently — only the autoscaler path logged. On a scale that didn't converge you couldn't tell from the operator log whether the reconciler had seen the change at all.

Does this PR introduce any user-facing change?

Operator log only. Example:
INFO HiveDependentResource: Scaling hiveserver2 lbodor-perf/hive-hiveserver2: 2 -> 1 replicas
INFO HiveDependentResource: Scaling metastore lbodor-perf/hive-metastore: 2 -> 1 replicas
INFO HiveClusterReconciler: Scaling llap lbodor-perf/hive-llap0: 12 -> 15 replicas
Silence still means "no change" — the log fires only on a real delta.

How was this patch tested?

Manually on an EKS cluster: scaled HS2, Metastore and LLAP up and down; confirmed the "Scaling …: A -> B replicas" line on each real change and no line when the count already matched.

@sonarqubecloud

Copy link
Copy Markdown

}
Integer current = Workloads.replicas(existing.get());
if (current != null && !current.equals(desired)) {
LOG.info("Scaling {} {}/{}: {} -> {} replicas", component, ns, name, current, desired);

@deniskuzZ deniskuzZ Sep 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Optional<R> existing = getSecondaryResource(primary, context);
Integer resolved = computeReplicaCount(primary, existing, autoscaling,
staticReplicas, initialReplicas);
logReplicaChange(primary, existing, resolved);

@deniskuzZ deniskuzZ Sep 17, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

? s.getSpec().getReplicas() : initialReplicas;
}
return initialReplicas;
Integer current = Workloads.replicas(existing.get());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

*/
private void logReplicaChange(P primary, Optional<R> existing, Integer desired) {
String component = getComponentName();
if (component == null || desired == null) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can the component be null?

@@ -208,17 +208,22 @@ public static PodDisruptionBudget buildPdb(HiveCluster hc, LlapSpec llap) {

/** TezAM Deployment/Service name for a specific LLAP cluster. */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we generalize log method or need both?

* 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) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants