-
Notifications
You must be signed in to change notification settings - Fork 103
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
base: master
Are you sure you want to change the base?
NO-ISSUE: Use max
to calculate operator resources
#2580
Conversation
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]>
@jhernand: This pull request explicitly references no jira issue. In response to this:
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. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jhernand 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 |
@jhernand: The following test failed, say
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. |
Currently the logic used to calculate resources for operators is like this:
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: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.