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

controllers: set storage utilization ratio in heartbeat #254

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

Conversation

rchikatw
Copy link
Contributor

@rchikatw rchikatw commented Oct 9, 2024

@rchikatw rchikatw force-pushed the uiclustername branch 5 times, most recently from 79fe559 to f9a97fd Compare October 9, 2024 09:36
@rchikatw
Copy link
Contributor Author

rchikatw commented Oct 9, 2024

@leelavg @nb-ohad please review.

service/status-report/main.go Outdated Show resolved Hide resolved
service/status-report/main.go Outdated Show resolved Hide resolved
service/status-report/main.go Outdated Show resolved Hide resolved
@rchikatw rchikatw force-pushed the uiclustername branch 4 times, most recently from 98a75ad to e159cf2 Compare October 14, 2024 05:15
@leelavg
Copy link
Contributor

leelavg commented Oct 14, 2024

LGTM. will wait for other review.

if ratio > 1 {
status.SetStorageQuotaUtilizationRatio(1)
} else {
status.SetStorageQuotaUtilizationRatio(float32(ratio))
Copy link
Contributor

Choose a reason for hiding this comment

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

are we going to show only ratio? and not capacity utilized

Copy link
Contributor

Choose a reason for hiding this comment

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

@rohan47 Because this is not about ODF capacity utilization, the quota reports the number of bytes out of the quota for total cluster storage utilization. I made the call to use ratio because we are talking about a number that describes how close we are to the quota, I agree that the world utilization here is problematic, but we couldn't find better terminology. If you have a suggestion for a more fitting terminology, please reply

klog.Warningf("Failed to get clusterResourceQuota %q: %v", clusterResourceQuota.Name, err)
}

if clusterResourceQuota.Status.Total.Hard != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we sure none of parts of .Status.Total.Hard is a pointer? If any is you will need a nil pointer check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have verified with multiple scenario.

Comment on lines 237 to 240
if ratio > 1 {
status.SetStorageQuotaUtilizationRatio(1)
} else {
status.SetStorageQuotaUtilizationRatio(float32(ratio))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. What if total is 0, you cannot divide by 0
  2. Why an if ... else ...? it makes more sense using math.Min to get the min between the ratio and 1

Copy link
Contributor Author

@rchikatw rchikatw Oct 14, 2024

Choose a reason for hiding this comment

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

  1. Total will never be zero here because we are creating a resource, and we will always have a value greater than 0. We can't generate a token with a value of 0 because that validation is added as part of the token generation API. I will include that in my upcoming commit once you let me know about my point 2. the validation for that edge case(If the client admin created a CRQ resource with a quota on a different resource.).
  2. math.Min is not available for float32 I have to do lot of to and from conversion like this
    status.SetStorageQuotaUtilizationRatio(float32(math.Min(float64(ratio), float64(1.0))))

@openshift-merge-robot
Copy link

PR needs rebase.

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.

Copy link

openshift-ci bot commented Oct 15, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rchikatw
Once this PR has been reviewed and has the lgtm label, please ask for approval from nb-ohad. 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

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.

5 participants