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

Add Sanity limits for persistent volumes #2051

Merged

Conversation

CampfireRemnants
Copy link
Contributor

What does this PR change?

  • It adds a sanity limit for PV byte usage, to preclude absurd inflated prices showing up. Currently, the Sanity Limit is set to 10 PetaBytes, but this can easily be changed, if appropriate. While a sanity limit is the current standard, it may be appropriate to consider a statistical outlier method, or an alternate clamping target.

Does this PR relate to any other PRs?

  • Negative

How will this PR impact users?

  • Users should no longer encounter an error with inflated PV costs in some circumstances.

Does this PR address any GitHub or Zendesk issues?

How was this PR tested?

  • Locally

Does this PR require changes to documentation?

  • Nope

Have you labeled this PR and its corresponding Issue as "next release" if it should be part of the next OpenCost release? If not, why not?

  • I would if it let me edit PR labels

const CPU_SANITY_LIMIT = 512

// Sanity Limit for PV usage, set to 10 PB, in bytes for now
const PV_USAGE_SANITY_LIMIT = 10737418240
Copy link
Contributor

Choose a reason for hiding this comment

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

Very small nit -- can we add _BYTES to the end of the name here? Trying to get the whole team on board for adding units to names when we can, to avoid ambiguity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Absolutely, that's a sensible semantic change

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

Copy link
Contributor

@nikovacevic nikovacevic left a comment

Choose a reason for hiding this comment

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

Just one thing to double-check here. (And I may be reading it backwards.)

Comment on lines 1824 to 1830
pvBytesUsed := res.Values[0].Value
if pvBytesUsed >= PV_USAGE_SANITY_LIMIT {
pvMap[key].Bytes = pvBytesUsed
} else {
pvMap[key].Bytes = 0
log.Infof("[WARNING] PV usage exceeds sanity limit, clamping to zero")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks backwards to me -- can we double-check? If the measured bytes exceed the limit, we want to clamp; if they do not exceed, we want to use the measured value, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, I accidentally swapped that, it's fixed now

… burndown list. Would benefit from actual outlier detection or clamping instead of just using a sanity limit.

Signed-off-by: Ashleigh <ashleigh@kubecost.com>
@nikovacevic nikovacevic merged commit 648bb5f into opencost:develop Jul 21, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants