-
Notifications
You must be signed in to change notification settings - Fork 315
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
fix: high resources panic #3984
Conversation
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #3984 +/- ##
==========================================
+ Coverage 41.93% 41.98% +0.04%
==========================================
Files 250 250
Lines 25015 25024 +9
==========================================
+ Hits 10490 10506 +16
+ Misses 13521 13516 -5
+ Partials 1004 1002 -2 |
pkg/k8s/deployments/crud.go
Outdated
if limitCpu, ok := dev.Resources.Limits[apiv1.ResourceCPU]; ok { | ||
manifestCpu = limitCpu.String() | ||
maximumCpuPerPodMatchGroups := cpuMaximumRegex.FindStringSubmatch(errorMessage) | ||
if len(maximumCpuPerPodMatchGroups) < 2 { |
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.
Why 2, can we put this value under a const with name?
pkg/k8s/deployments/crud.go
Outdated
if limitMemory, ok := dev.Resources.Limits[apiv1.ResourceMemory]; ok { | ||
manifestMemory = limitMemory.String() | ||
maximumMemoryPerPodMatchGroups := memoryMaximumRegex.FindStringSubmatch(errorMessage) | ||
if len(maximumMemoryPerPodMatchGroups) < 2 { |
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.
same :)
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.
nit: just comment on a value, overrall LGTM
pkg/k8s/deployments/crud_test.go
Outdated
if err.Error() != tt.expectedErr.Error() { | ||
t.Fatalf("wrong error. Got %s, expected %s", err, tt.expectedErr) | ||
if err != nil && tt.expectedErr == nil { | ||
t.Fatalf("wrong error. Got nil, expected %s", err.Error()) |
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.
t.Fatalf("wrong error. Got nil, expected %s", err.Error()) | |
t.Fatalf("wrong error. Expected nil, but got %s", err.Error()) |
Signed-off-by: Javier López Barba <javier@okteto.com>
Proposed changes
Fixes #3841
Fix a panic that was happening when the message produced by k8s was missing any resource and limit. Given that I was not able to reproduce it, I added tests covering the use cases where the error could happen based on the logs provided.
How to validate
Check unit tests. No way to reproduce the issue on any cluster. I just could reproduce it on unit tests.
CLI Quality Reminders 🔧
For both authors and reviewers: