Skip to content

SSABasedGenericKubernetesResourceMatcher: HorizontalPodAutoscaler target quantities never match (1000 vs 1k) #3681

Closed

Description

@cjbooms

Bug Report

What did you do?

A dependent HorizontalPodAutoscaler (autoscaling/v2) declares an external metric with target.averageValue: "1000". The API server stores this value in canonical form, as "1k". The default SSABasedGenericKubernetesResourceMatcher compares the two strings, so matches returns false on every reconcile and the operator re-applies the HPA each time.

PodTemplateSpecSanitizer already solves this class of problem for StatefulSet, Deployment, ReplicaSet and DaemonSet pod templates. sanitizeState has no branch for HorizontalPodAutoscaler, so HPA quantities are never normalised. This is the same root cause as #2509, for a different kind.

What did you expect to see?

A numerically equal stored quantity matches the desired quantity, as it does for container resources in pod templates.

What did you see instead?

The matcher reports a mismatch on every reconcile. The operator log shows the same diff each time: replace /spec/metrics/0/external/target/averageValue with value 1000.

I checked this against a real API server (k3s v1.31.4) with JOSDK 5.1.4 and fabric8 7.3.1. The desired object was applied with server-side apply. The stored object was then read back and compared with SSABasedGenericKubernetesResourceMatcher.getInstance():

Desired averageValue / value Stored by the API server Matcher result
1000 1k no match
0.5 500m no match
2000m 2 no match
1500 1500 match

sanitizeState on main still contains branches only for StatefulSet, Deployment, ReplicaSet and DaemonSet, so this appears to be unchanged in newer releases. I did not run 5.6.x.

Workaround

Subclass the matcher and override sanitizeState. When the stored and desired quantities are numerically equal (Quantity.equals), copy the desired string into actualMap. Register the subclass with KubernetesDependentResourceConfigBuilder.withSSAMatcher. This is the approach PodTemplateSpecSanitizer.sanitizeQuantities uses. With it, the HPA no longer re-applies, and a real change to the target is still detected and applied once.

Proposal

Add an HorizontalPodAutoscaler branch to sanitizeState. It would normalise value and averageValue in spec.metrics[*].{external,object,pods,resource,containerResource}.target. Would a PR for this be welcome?

Environment

  • JOSDK: 5.1.4
  • fabric8 kubernetes-client: 7.3.1
  • Kubernetes: v1.31.4 (k3s)

Activity

  1. added 3 commits that reference this issue on Nov 6, 2026
    ab1f8e5
    08b7f9c
    8037c25
  2. added a commit that references this issue on Nov 6, 2026
    c4b023b
  3. added a commit that references this issue on Nov 9, 2026
    5cd15ad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions