Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NO-ISSUE: Use max to calculate operator resources #2580

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhernand
Copy link
Contributor

Currently the logic used to calculate resources for operators is like this:

def resource_param(base_value: int, resource_name: str, operator: str, is_sno: bool = False):
    try:
        value = base_value
        resource = consts.OperatorResource.values(is_sno)[operator][resource_name]
        if value <= resource:
            value = value + resource
        return value
     except KeyError as e:
         raise ValueError(f"Unknown operator name {e.args[0]}") from e

For example, the default for resource worker_count is 2, and with this logic there is no way to specify that 3 workers are required:

Default Operator Result
2 0 2
2 1 2
2 2 4
2 3 5
2 4 6

As you can see the actual value jumps from 2 to 4, and there is no way to get 3 as the result, no mather what is the requirement of the operator.

The same happens for other resources, like memory or CPU.

It would be more useful to calculate the actual value as the maximum of the default and the value required by the operator. This is what this patch does.

Currently the logic used to calculate resources for operators is
like this:

```python
def resource_param(base_value: int, resource_name: str, operator: str, is_sno: bool = False):
    try:
        value = base_value
        resource = consts.OperatorResource.values(is_sno)[operator][resource_name]
        if value <= resource:
            value = value + resource
        return value
     except KeyError as e:
         raise ValueError(f"Unknown operator name {e.args[0]}") from e
```

For example, the default for resource `worker_count` is 2, and with this
logic there is no way to specify that 3 workers are required:

| Default | Operator | Result |
| ------- | --------- | ------|
| 2       | 0         | 2     |
| 2       | 1         | 2     |
| 2       | 2         | 4     |
| 2       | 3         | 5     |
| 2       | 4         | 6     |

As you can see the actual value jumps from 2 to 4, and there is no way
to get 3 as the result, no mather what is the requirement of the
operator.

The same happens for other resources, like memory or CPU.

It would be more useful to calculate the actual value as the maximum of
the default and the value required by the operator. This is what this
patch does.

Signed-off-by: Juan Hernandez <[email protected]>
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Nov 28, 2024
@openshift-ci-robot
Copy link

@jhernand: This pull request explicitly references no jira issue.

In response to this:

Currently the logic used to calculate resources for operators is like this:

def resource_param(base_value: int, resource_name: str, operator: str, is_sno: bool = False):
   try:
       value = base_value
       resource = consts.OperatorResource.values(is_sno)[operator][resource_name]
       if value <= resource:
           value = value + resource
       return value
    except KeyError as e:
        raise ValueError(f"Unknown operator name {e.args[0]}") from e

For example, the default for resource worker_count is 2, and with this logic there is no way to specify that 3 workers are required:

Default Operator Result
2 0 2
2 1 2
2 2 4
2 3 5
2 4 6

As you can see the actual value jumps from 2 to 4, and there is no way to get 3 as the result, no mather what is the requirement of the operator.

The same happens for other resources, like memory or CPU.

It would be more useful to calculate the actual value as the maximum of the default and the value required by the operator. This is what this patch does.

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 avishayt and danmanor November 28, 2024 19:46
@openshift-ci openshift-ci bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Nov 28, 2024
Copy link

openshift-ci bot commented Nov 28, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jhernand
Once this PR has been reviewed and has the lgtm label, please assign adriengentil for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link

openshift-ci bot commented Nov 28, 2024

@jhernand: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/e2e-metal-assisted-kube-api-late-binding-single-node 4c65110 link false /test e2e-metal-assisted-kube-api-late-binding-single-node

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants