Repository navigation
fix(webhook): use coreRequest for CPU requests in quota enforcement - #3279
Open
parth-patel010 wants to merge 1 commit into
Open
parth-patel010 wants to merge 1 commit into
parth-patel010 wants to merge 1 commit into
Conversation
Spark sets the driver and executor pod CPU request from
spark.kubernetes.{driver,executor}.request.cores when it is given and
only falls back to cores otherwise. The quota check ignored coreRequest,
so apps were rejected or admitted based on cores instead of what their
pods actually request.
Fixes kubeflow#3278
Signed-off-by: parth-patel010 <parthp12321@gmail.com>
Contributor
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
With resource quota enforcement enabled, the webhook computed a SparkApplication's CPU requests from
coresonly and ignoreddriver.coreRequest/executor.coreRequest. Spark sets the pod CPU request fromspark.kubernetes.{driver,executor}.request.coreswhen it's given (that's whatcoreRequestmaps to) and only falls back tospark.{driver,executor}.coresotherwise. So apps likecores: 4, coreRequest: 500mwere rejected for needing 4 CPUs per pod, and apps withcoreRequestabovecoresgot past the check.Fixes #3278
Proposed changes:
getSparkPodCoresRequestsnow takes the pod'scoreRequestand, when it is set, parses it as a quantity and uses it forcpu/requests.cpu. Otherwise it keeps usingcores(or the default of 1), as before. This matches whatinternal/scheduler/yunikorn/resourceusagealready does.coreRequestreturns an error (failed to parse coreRequest "one": ...), so the webhook rejects the app instead of silently falling back tocores. This is the same way an invalidcoreLimitis already handled.limits.cpuis not changed. It is still based oncoreLimit, thencores.Change Category
Rationale
The quota check should count what the pods will actually request. Apps that don't set
coreRequestget exactly the same numbers as before.Checklist
Additional Notes
New tests
TestGetResourceListCoreRequestcheckscpu,requests.cpuandlimits.cpuin four cases: cores only, coreRequest below cores, coreRequest above cores, and a decimal coreRequest (0.5).TestGetResourceListInvalidCoreRequestchecks that an invalid coreRequest returns an error.requests.cpu: 3quota. In the first, the app needs 2.5 CPUs of requests but has 12 cores, and it must be admitted. In the second, the app needs 6 CPUs of requests but has 3 cores, and it must be rejected.Before (master d016731 + the new tests):
After:
Full unit test suite (same packages as
make unit-test, envtest 1.35.0):golangci-lint run ./internal/webhook/...reports 0 issues, andgo vetandgofmtare clean.This touches the same file as #3258 and #3269, but different functions (the CPU path rather than the memory path), so they don't overlap.