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
Machine resource quota webhook #9650
Machine resource quota webhook #9650
Conversation
918eff1
to
eac438b
Compare
pkg/controller/user-cluster-controller-manager/resources/resources/machine/webhook.go
Outdated
Show resolved
Hide resolved
combinedUsage.Storage().Add(*quotaReq.Storage()) | ||
|
||
if quota.Cpu().Cmp(*combinedUsage.Cpu()) < 0 { | ||
log.Debugf("requested CPU %q would exceed current quota (quota/used %q/%q)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love readable log messages, but should we use structured logging here? Honest question. "No." is a valid answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to structured, looks better
NewResourceQuota(cpuUsed, memUsed, storageUsed), nil | ||
} | ||
|
||
type ResourceQuota struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct seems to be used not just for quotas, but also to express the current consumption. So the name for this struct might be a bit unfortunate. What about ResourceDetails
maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using corev1.ResourceList
? That one looks super similar, maybe similar enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first thought and implementation was with corev1.ResourceList
, but it has some additional things like ResourceEphemeralStorage
and Pods() which I thought could make it confusing. So I decided on something simpler
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few nits here and there.
eac438b
to
87570be
Compare
/retest |
2 similar comments
/retest |
/retest |
/retest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
LGTM label has been added. Git tree hash: 258e9f13f8b41d274676dd40ca59ec036fd14b92
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lsviben, xrstf 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 |
What does this PR do / Why do we need it:
Part of #9412. This PR adds a machine validating webhook for resource quotas.
As we dont have yet the ResourceQuotas for projects implemented, or its calculation, so for now getting the quotas are hardcoded with some fake value. Also getting the resource requirements for the machine, per provider, will be implemented in the next PRs, so for now no providers are supported - meaning the webhook wont do anything yet and will just pass the validation.
What this PR brings is the scaffolding of the resource quota validation, with the checks for requested resources vs. quota and current quota usage.
Does this PR close any issues?:
Fixes #9625
Does this PR introduce a user-facing change?: