-
-
Notifications
You must be signed in to change notification settings - Fork 853
Feat: Can override machine request and limit independently for kubernetes #2469
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
Changes from all commits
0124ba3
aea8378
6e21e01
77edb1f
5e8188b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -296,8 +296,8 @@ export class KubernetesWorkloadManager implements WorkloadManager { | |||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
#getResourceRequestsForMachine(preset: MachinePreset): ResourceQuantities { | ||||||||||||||||||||||||||||||||||
return { | ||||||||||||||||||||||||||||||||||
cpu: `${preset.cpu * 0.75}`, | ||||||||||||||||||||||||||||||||||
memory: `${preset.memory}G`, | ||||||||||||||||||||||||||||||||||
cpu: `${preset.cpuRequest ?? preset.cpu * 0.75}`, | ||||||||||||||||||||||||||||||||||
memory: `${preset.memoryRequest ?? preset.memory}G`, | ||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
Comment on lines
297
to
302
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Clamp requests to limits to avoid K8s 400s on misconfiguration Even with schema checks, defensive clamping avoids failed pod creations when overrides drift or come from older configs. #getResourceRequestsForMachine(preset: MachinePreset): ResourceQuantities {
- return {
- cpu: `${preset.cpuRequest ?? preset.cpu * 0.75}`,
- memory: `${preset.memoryRequest ?? preset.memory}G`,
- };
+ const cpuReq = Math.min(Math.max(0, preset.cpuRequest ?? preset.cpu * 0.75), preset.cpu);
+ const memReq = Math.min(Math.max(0, preset.memoryRequest ?? preset.memory), preset.memory);
+ return {
+ cpu: `${cpuReq}`,
+ memory: `${memReq}G`,
+ };
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
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.
🛠️ Refactor suggestion
Clamp requests to limits (mirror supervisor change)
Prevents admission failures when overrides set requests above limits.
📝 Committable suggestion
🤖 Prompt for AI Agents