Skip to content
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

Merged
merged 3 commits into from
Sep 27, 2023
Merged

Conversation

jLopezbarb
Copy link
Contributor

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:

  • Scrutinize for potential regressions
  • Ensure key automated tests are in place
  • Build the CLI and test using the validation steps
  • Assess Developer Experience impact (log messages, performances, etc)
  • If too broad, consider breaking into smaller PRs
  • Adhere to our code style and code review guidelines

Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
@codecov
Copy link

codecov bot commented Sep 20, 2023

Codecov Report

Merging #3984 (166295c) into master (8a0f114) will increase coverage by 0.04%.
Report is 4 commits behind head on master.
The diff coverage is 100.00%.

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     

if limitCpu, ok := dev.Resources.Limits[apiv1.ResourceCPU]; ok {
manifestCpu = limitCpu.String()
maximumCpuPerPodMatchGroups := cpuMaximumRegex.FindStringSubmatch(errorMessage)
if len(maximumCpuPerPodMatchGroups) < 2 {
Copy link
Member

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?

if limitMemory, ok := dev.Resources.Limits[apiv1.ResourceMemory]; ok {
manifestMemory = limitMemory.String()
maximumMemoryPerPodMatchGroups := memoryMaximumRegex.FindStringSubmatch(errorMessage)
if len(maximumMemoryPerPodMatchGroups) < 2 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same :)

Copy link
Member

@teresaromero teresaromero left a 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

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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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>
@jLopezbarb jLopezbarb merged commit 99379ab into master Sep 27, 2023
13 checks passed
@jLopezbarb jLopezbarb deleted the jlopezbarb/fix-panic-high-resources branch September 27, 2023 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

I got a panic error when executing okteto up and my resources.requests are too high
4 participants