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

Bug 1949387: Fix the typo in reserved calculation in auto sizing script #2527

Merged
merged 1 commit into from Apr 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 6 additions & 5 deletions templates/common/_base/files/kubelet-auto-sizing.yaml
Expand Up @@ -37,7 +37,7 @@ contents:
recommended_systemreserved_memory=$(echo $recommended_systemreserved_memory 6.72 | awk '{print $1 + $2}')
total_memory=$((total_memory-112))
fi
if (($total_memory >= 128)); then # 2% of any memory above 128GB
if (($total_memory >= 0)); then # 2% of any memory above 128GB
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was a bug, if the memory was above 128 without this fix it will yield incorrect result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

memory    reserved 
128           9.32Gi
129           9.34Gi
130           9.36Gi

after 128, add 2% of the remaining memory to the reserved.

recommended_systemreserved_memory=$(echo $recommended_systemreserved_memory $(echo $total_memory 0.02 | awk '{print $1 * $2}') | awk '{print $1 + $2}')
fi
echo "SYSTEM_RESERVED_MEMORY=${recommended_systemreserved_memory}Gi">> ${NODE_SIZES_ENV}
Expand All @@ -46,15 +46,16 @@ contents:
total_cpu=$(getconf _NPROCESSORS_ONLN)
recommended_systemreserved_cpu=0
if (($total_cpu <= 1)); then # 6% of the first core
recommended_systemreserved_cpu=$(echo $total_cpu 0.60 | awk '{print $1 * $2}')
recommended_systemreserved_cpu=$(echo $total_cpu 0.06 | awk '{print $1 * $2}')
Copy link
Contributor Author

@harche harche Apr 14, 2021

Choose a reason for hiding this comment

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

A typo, we need to get 6% of the CPU. Because of the typo, it was getting 60%. However, since we never have system in CI or in production with just 1 CPU. This bug never surfaced.

total_cpu=0
else
recommended_systemreserved_cpu=0.06
total_cpu=$((total_cpu-1))
fi
if (($total_cpu <= 1)); then # 1% of the next core (up to 2 cores)
recommended_systemreserved_cpu=$(echo $recommended_systemreserved_cpu $(echo $total_cpu 0.10 | awk '{print $1 * $2}') | awk '{print $1 + $2}')
total_cpu=0 else
recommended_systemreserved_cpu=$(echo $recommended_systemreserved_cpu $(echo $total_cpu 0.01 | awk '{print $1 * $2}') | awk '{print $1 + $2}')
total_cpu=0
else
Copy link
Contributor Author

Choose a reason for hiding this comment

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

else in this line was misplaced.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, there was a typo on line 56 where we wanted to get 1% of CPU but we were getting 10%.

recommended_systemreserved_cpu=$(echo $recommended_systemreserved_cpu 0.01 | awk '{print $1 + $2}')
total_cpu=$((total_cpu-1))
fi
Expand All @@ -65,7 +66,7 @@ contents:
recommended_systemreserved_cpu=$(echo $recommended_systemreserved_cpu 0.01 | awk '{print $1 + $2}')
total_cpu=$((total_cpu-2))
fi
if (($total_cpu >= 4)); then # 0.25% of any cores above 4 cores
if (($total_cpu >= 0)); then # 0.25% of any cores above 4 cores
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a bug too. Above 4 cores, without this fix we would start to slightly deviate away from the desired output.

Copy link
Contributor Author

@harche harche Apr 14, 2021

Choose a reason for hiding this comment

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

Core       Reserved Value
1              0.06
2              0.07
3              0.075
4              0.08
5              0.0825

after 4, keep adding 0.0025 for per cpu core

recommended_systemreserved_cpu=$(echo $recommended_systemreserved_cpu $(echo $total_cpu 0.0025 | awk '{print $1 * $2}') | awk '{print $1 + $2}')
fi
echo "SYSTEM_RESERVED_CPU=${recommended_systemreserved_cpu}">> ${NODE_SIZES_ENV}
Expand Down