fix: Patch memory resources being duplicated #2866
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2866"
general
weight: 0.35
vjanelle
<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, check our contributor guidelines: https://www.kubeflow.org/docs/about/contributing
2. To know more about how to develop with the Spark operator, check the developer guide: https://www.kubeflow.org/docs/components/spark-operator/developer-guide/
3. If you want faster PR reviews, check how: https://git.k8s.io/community/contributors/guide/pull-requests.md#best-practices-for-faster-reviews
4. Please open an issue to discuss significant work before you start. We appreciate your contributions and don't want your efforts to go to waste!
-->
Purpose of this PR
This PR is to fix an error where memory requests are doubled for spark applications when quota enforcement is enabled. The changes added are in two main categories listed below.
IMPORTANT NOTE: Before merge, I will add some additional tests to validate this logic. Putting up the PR now for some early feedback.
Proposed changes:
1. Fix the memory resource validation
2. Add more information when resources are rejected
3. Other misc things
- Add a default for when no memory is set here
Change Category
<!-- Indicate the type of change by marking the applicable boxes. -->
Rationale
For the changes respectively:
1. Resource quotas for memory do not seem to be evaluated correctly.
2. Add more informative information so a user can know which resource they are exceeding.
Checklist
<!-- Before submitting your PR, please review the following: -->
Additional Notes
Change 2 - Add more information when resources are rejected.
First I will explain the new error message because that is simple. With a change to validateResourceQuota and validateResourceUsage the new error message looks like:
This matches the native Spark K8 integration more closely and removes guess work.
Change 1 - Fix the memory resource validation.
At a high level, because
getSparkPodMemoryRequestswas settingmemoryandrequests.memoryheregetMemoryLimitsreused this function hereThen this SumResourceList will double
memoryandrequests.memory.This can be seen while running the
examples/spark-pi.yamlafter enabling--enable-resource-quota-enforcement=trueand with the following resource quota:This is what produced the error message shown above.
As this error message states, the calculated requested memory is
3584Mi. However this spark job only requests512mfor the driver and a single executor (see here). This plus the default overhead should give us a total application request of:However due to the reasons shown above we are getting:
This PR changes
getSparkPodMemoryRequests(renamedgetSparkPodMemory) andgetMemoryRequests(renamedgetMemory) to return a simpleint64. ThengetMemoryRequestsandgetMemoryLimitsset the specific resource name here.Because this will now produce
memory,requests.memoryandlimits.memorywithout any key duplicated, then the doubling is removed.Another note: This is my first commit to the spark-operator side of kubeflow so if there is any convention which I should be following and I have neglected, please let me know and I will make changes :+1: