Skip to content

Conversation

@cajieh
Copy link
Contributor

@cajieh cajieh commented Oct 22, 2025

The Alignment Between HPA Form Behavior and the API

A breakdown of the key points regarding the Horizontal Pod Autoscaler (HPA) form's behavior and how it aligns with API:

API Default Behavior:
If the spec.metrics array in an HPA manifest is empty ([]) or omitted, API automatically defaults to scaling based on 80% average CPU utilization.

API Validation Rule for Utilization:
If you specify a metric with target.type utilization (like CPU or Memory), the averageUtilization value "must be greater than 0". A value of 0 is invalid and will be rejected by the Kubernetes API server.

UI Form Behavior:
Empty Input Field: If a user leaves the CPU or Memory utilization field empty, the UI omits that specific metric from the generated HPA manifest/request.

  • This allows users to create single-metric HPAs (e.g., Memory only).
  • If both fields are left empty, API applies its 80% CPU default.

Input Value = '0': If a user enters 0 in the CPU or Memory utilization field, the UI sends this value to the API server. The API server then rejects the request with the "must be greater than 0" error, which is the current and expected behavior.

Input Value > 0: The UI includes the specified metric values in the HPA manifest/request, which are then sent successfully to the API.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 22, 2025
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 22, 2025
@openshift-ci-robot openshift-ci-robot added the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Oct 22, 2025
@openshift-ci-robot
Copy link
Contributor

@cajieh: This pull request references Jira Issue OCPBUGS-63339, which is invalid:

  • expected the bug to target the "4.21.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

…Memory Metrics

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested review from sg00dwin and spadgett October 22, 2025 00:25
@openshift-ci openshift-ci bot added component/dev-console Related to dev-console approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 22, 2025
@yanpzhan
Copy link
Contributor

yanpzhan commented Oct 22, 2025

@cajieh Checked on cluster launched against the pr. On HPA create/edit form view page, user could set '0' for CPU Utilization。
But when set '0' for Memory Utilization, it still prompts error "Danger alert:An error occurred
Error "Invalid value: 0: must be greater than 0" for field "spec.metrics[1].resource.target.averageUtilization"."
If user set '0' for CPU Utilization, set a valid number eg '10' for Memory Utilization, HPA could be created/saved, but there will be duplicated memory metrics info in yaml.

# oc get hpa example -n protest --kubeconfig 15626.kubeconfig -ojson | jq '.spec.metrics'
[
  {
    "resource": {
      "name": "memory",
      "target": {
        "averageUtilization": 10,
        "type": "Utilization"
      }
    },
    "type": "Resource"
  },
  {
    "resource": {
      "name": "memory",
      "target": {
        "averageUtilization": 10,
        "type": "Utilization"
      }
    },
    "type": "Resource"
  }
]

Screenshot from 2025-10-22 19-25-18

@cajieh
Copy link
Contributor Author

cajieh commented Oct 22, 2025

@cajieh Checked on cluster launched against the pr. On HPA create/edit form view page, user could set '0' for CPU Utilization。 But when set '0' for Memory Utilization, it still prompts error "Danger alert:An error occurred Error "Invalid value: 0: must be greater than 0" for field "spec.metrics[1].resource.target.averageUtilization"." If user set '0' for CPU Utilization, set a valid number eg '10' for Memory Utilization, HPA could be created/saved, but there will be duplicated memory metrics info in yaml.

# oc get hpa example -n protest --kubeconfig 15626.kubeconfig -ojson | jq '.spec.metrics'
[
  {
    "resource": {
      "name": "memory",
      "target": {
        "averageUtilization": 10,
        "type": "Utilization"
      }
    },
    "type": "Resource"
  },
  {
    "resource": {
      "name": "memory",
      "target": {
        "averageUtilization": 10,
        "type": "Utilization"
      }
    },
    "type": "Resource"
  }
]
Screenshot from 2025-10-22 19-25-18

@cajieh cajieh closed this Oct 22, 2025
@cajieh cajieh reopened this Oct 22, 2025
@openshift-ci-robot
Copy link
Contributor

@cajieh: This pull request references Jira Issue OCPBUGS-63339. The bug has been updated to no longer refer to the pull request using the external bug tracker. All external bug links have been closed. The bug has been moved to the NEW state.

In response to this:

…Memory Metrics

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link
Contributor

@cajieh: This pull request references Jira Issue OCPBUGS-63339, which is invalid:

  • expected the bug to target the "4.21.0" version, but no target version was set

Comment /jira refresh to re-evaluate validity if changes to the Jira bug are made, or edit the title of this pull request to link to a different bug.

The bug has been updated to refer to the pull request using the external bug tracker.

In response to this:

…Memory Metrics

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@cajieh cajieh force-pushed the hpa-from-requires-both-cpu-mem-utilizations branch from d09a758 to 35a092d Compare October 22, 2025 14:09
@openshift-ci openshift-ci bot added the component/core Related to console core functionality label Oct 22, 2025
@cajieh cajieh force-pushed the hpa-from-requires-both-cpu-mem-utilizations branch 3 times, most recently from f98cf90 to 7ef01fc Compare October 22, 2025 15:22
@cajieh
Copy link
Contributor Author

cajieh commented Oct 22, 2025

duplicated memory metrics info in yaml

@yanpzhan Thank you for verifying quickly. However, the error—Error "Invalid value: 0: must be greater than 0" for field "spec.metrics[1].resource.target.averageUtilization" is coming directly from the API server. This behavior is expected for both CPU and Memory Utilization, as Kubernetes validation requires the averageUtilization value to be greater than 0.
Also, in the scenario where a user sets '0' for CPU Utilization but provides a valid number (e.g., '10') for Memory Utilization, HPA creation should fail and throw an API server error. But it appears the console UI might be removing the '0' value for CPU before sending the request. However, the HPA can be created without defining both the CPU and Memory averageUtilization values.
The issue with duplicated Memory metrics info in the YAML will be fixed.

@cajieh cajieh force-pushed the hpa-from-requires-both-cpu-mem-utilizations branch from 7ef01fc to d7d60e1 Compare October 22, 2025 16:09
@cajieh cajieh force-pushed the hpa-from-requires-both-cpu-mem-utilizations branch from d7d60e1 to 948b438 Compare October 22, 2025 16:28
name: cpu
target:
averageUtilization: 50
averageUtilization: 80
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unsure why the default value for the UI was different from the API default. Changed it to be consistent with the API default.

@cajieh cajieh changed the title [WIP] OCPBUGS-63339: HPA Form View in RHOCP Web Console Incorrectly Requires Both CPU and … OCPBUGS-63339: HPA Form View in RHOCP Web Console Incorrectly Requires Both CPU and … Oct 22, 2025
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 22, 2025
@yanpzhan
Copy link
Contributor

@cajieh when create HPA on form view, leave CPU Utilization and Memory Utilization fields empty, click create. The hpa will only have default value 80 for CPU Utilization, so if there is not a requirement for Memory Utilization default value?

@cajieh
Copy link
Contributor Author

cajieh commented Oct 23, 2025

@cajieh when create HPA on form view, leave CPU Utilization and Memory Utilization fields empty, click create. The hpa will only have default value 80 for CPU Utilization, so if there is not a requirement for Memory Utilization default value?

@yanpzhan Correct. This change removes the default value for the Memory Utilization field. The intention is to align with the oc CLI's behavior, unless anyone has a strong justification for not doing so.
cc: @vikram-raj @jhadvig

@cajieh
Copy link
Contributor Author

cajieh commented Oct 23, 2025

/test okd-scos-e2e-aws-ovn

@cajieh
Copy link
Contributor Author

cajieh commented Oct 23, 2025

/jira refresh

@openshift-ci-robot openshift-ci-robot added the jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. label Oct 23, 2025
@openshift-ci-robot
Copy link
Contributor

@cajieh: This pull request references Jira Issue OCPBUGS-63339, which is valid. The bug has been moved to the POST state.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (4.21.0) matches configured target version for branch (4.21.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, POST)

Requesting review from QA contact:
/cc @yapei

In response to this:

/jira refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot removed the jira/invalid-bug Indicates that a referenced Jira bug is invalid for the branch this PR is targeting. label Oct 23, 2025
@openshift-ci openshift-ci bot requested a review from yapei October 23, 2025 20:30
@yanpzhan
Copy link
Contributor

The update LGTM now.
/verified by @yanpzhan

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Oct 24, 2025
@openshift-ci-robot
Copy link
Contributor

@yanpzhan: This PR has been marked as verified by @yanpzhan.

In response to this:

The update LGTM now.
/verified by @yanpzhan

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@cajieh
Copy link
Contributor Author

cajieh commented Nov 3, 2025

/retest

Copy link
Member

@vikram-raj vikram-raj left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Nov 4, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 4, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cajieh, vikram-raj

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 4, 2025

@cajieh: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit 705c494 into openshift:main Nov 4, 2025
8 checks passed
@openshift-ci-robot
Copy link
Contributor

@cajieh: Jira Issue Verification Checks: Jira Issue OCPBUGS-63339
✔️ This pull request was pre-merge verified.
✔️ All associated pull requests have merged.
✔️ All associated, merged pull requests were pre-merge verified.

Jira Issue OCPBUGS-63339 has been moved to the MODIFIED state and will move to the VERIFIED state when the change is available in an accepted nightly payload. 🕓

In response to this:

The Alignment Between HPA Form Behavior and the API

A breakdown of the key points regarding the Horizontal Pod Autoscaler (HPA) form's behavior and how it aligns with API:

API Default Behavior:
If the spec.metrics array in an HPA manifest is empty ([]) or omitted, API automatically defaults to scaling based on 80% average CPU utilization.

API Validation Rule for Utilization:
If you specify a metric with target.type utilization (like CPU or Memory), the averageUtilization value "must be greater than 0". A value of 0 is invalid and will be rejected by the Kubernetes API server.

UI Form Behavior:
Empty Input Field: If a user leaves the CPU or Memory utilization field empty, the UI omits that specific metric from the generated HPA manifest/request.

  • This allows users to create single-metric HPAs (e.g., Memory only).
  • If both fields are left empty, API applies its 80% CPU default.

Input Value = '0': If a user enters 0 in the CPU or Memory utilization field, the UI sends this value to the API server. The API server then rejects the request with the "must be greater than 0" error, which is the current and expected behavior.

Input Value > 0: The UI includes the specified metric values in the HPA manifest/request, which are then sent successfully to the API.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@cajieh
Copy link
Contributor Author

cajieh commented Nov 4, 2025

/cherry-pick release-4.20

@openshift-cherrypick-robot

@cajieh: new pull request created: #15673

In response to this:

/cherry-pick release-4.20

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/dev-console Related to dev-console jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants