-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Rewrite addon-resizer nanny #128
Conversation
/assign @mwielgus |
addon-resizer/Makefile
Outdated
@@ -25,7 +25,7 @@ | |||
OUT_DIR = build | |||
PACKAGE = k8s.io/contrib/addon-resizer | |||
PREFIX = gcr.io/google_containers | |||
TAG = 1.7 | |||
TAG = 1.8 |
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.
it is a significant rewrite - lets bump it to 2.0
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.
Ok.
addon-resizer/nanny/estimator.go
Outdated
|
||
log "github.com/golang/glog" |
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.
imports:
core-go
blank line
kubernetes
blank line
3rd-party
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.
And your point is...? :-) Note that nanny_lib was already using glog.
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.
wrong import order
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.
Oh, you meant the order. Fixed.
db94731
to
a4440c3
Compare
addon-resizer/nanny/estimator.go
Outdated
Resources []Resource | ||
// ResourceListPair is a pair of ResourceLists, denoting a range. | ||
type ResourceListPair struct { | ||
lower, upper api.ResourceList |
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.
what exactly is lower/upper? is it min/max? please document.
addon-resizer/nanny/estimator.go
Outdated
return calculateResources(numNodes, e.Resources) | ||
// EstimatorResult is the result of the resource Estimation, used by Estimator struct. | ||
type EstimatorResult struct { | ||
RecommendedRange, AcceptableRange ResourceListPair |
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.
All public fields must have documentation.
One field per line.
addon-resizer/nanny/estimator.go
Outdated
ScaleFactor float64 | ||
// Estimator is a struct used for estimating accepted and recommended resource requirements. | ||
type Estimator struct { | ||
Resources []Resource |
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.
Doc.
pollPeriod = time.Millisecond * time.Duration(*flag.Int("poll-period", 10000, "The time, in milliseconds, to poll the dependent container.")) | ||
estimator = flag.String("estimator", "linear", "The estimator to use. Currently supported: linear, exponential") | ||
pollPeriodMillis = flag.Int("poll-period", 10000, "The time, in milliseconds, to poll the dependent container.") | ||
estimator = flag.String("estimator", "linear", "[DEPRECATED] No-op. Can be set to: linear, exponential") |
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.
Remove.
memoryPerNode = flag.String("extra-memory", "0Mi", "The amount of memory to add per node.") | ||
baseStorage = flag.String("storage", noValue, "The base storage resource requirement.") | ||
storagePerNode = flag.String("extra-storage", "0Gi", "The amount of storage to add per node.") | ||
threshold = flag.Int("threshold", 0, "[DEPRECATED] Please use recommendation-offset and acceptance-offset istead.\nA number between 0-100. The dependent's resources are rewritten when they deviate from expected by more than threshold.") |
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.
Remove.
) | ||
|
||
func checkPercentageBounds(flagName string, flagValue int) { |
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.
checkPercentageFlagBounds
checkPercentageBounds("acceptance-offset", *acceptanceOffset) | ||
|
||
pollPeriod := time.Millisecond * time.Duration(*pollPeriodMillis) | ||
log.Infof("Poll period: %+v", pollPeriod) | ||
log.Infof("Watching namespace: %s, pod: %s, container: %s.", *podNamespace, *podName, *containerName) | ||
log.Infof("cpu: %s, extra_cpu: %s, memory: %s, extra_memory: %s, storage: %s, extra_storage: %s", *baseCPU, *cpuPerNode, *baseMemory, *memoryPerNode, *baseStorage, *storagePerNode) |
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.
What about printing bounds?
Resources: resources, | ||
ScaleFactor: 1.5, | ||
} | ||
if *estimator == "linear" || *estimator == "exponential" { |
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.
AFAIR this was about to be a noop.
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.
Remove.
addon-resizer/nanny/nanny_lib.go
Outdated
func shouldOverwriteResources(estimatorResult *EstimatorResult, limits, reqs api.ResourceList) *api.ResourceRequirements { | ||
for _, list := range []api.ResourceList{limits, reqs} { | ||
for _, resourceType := range []api.ResourceName{api.ResourceCPU, api.ResourceMemory, api.ResourceStorage} { | ||
p := checkResource(estimatorResult, list, resourceType) |
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.
what is p? Please use full names.
Please explain how the PR was tested. |
9ff39be
to
7df7cde
Compare
Apart from unit tests, I ran a manual integration test, setting up my own Kubernetes cluster on GCE and resizing it in a way described in the doc (example scenario) linked in the first post & verifying changes occur as expected. |
Doesn't compile. |
There will be a single estimator class, providing two ranges: acceptable and recommended range. As long as current pod requirements and limits fall into acceptable range, nothing happens. Once either limits or requirements fall out of acceptable range, they are both updated to lower (when upscaling) or higher (when downscaling) end of recommended range. This approach prevents flapping, which took place in previous implementation, when cluster size oscillated around certain values. Also, fix the code to actually use poll-period flag.
Does compile. |
Fixes kubernetes/kubernetes#30446. |
LGTM |
…rry-pick-125-to-release-4.4 [release-4.4] BUG 1805153: Ensure DeleteNodes doesn't delete a node twice
Fix RBAC after adding Priority support
There will be a single estimator class, providing two ranges: acceptable
and recommended range. As long as current pod requirements and limits fall into
acceptable range, nothing happens. Once either limits or requirements
fall out of acceptable range, they are both updated to lower (when
upscaling) or higher (when downscaling) end of recommended range. This
approach prevents flapping, which took place in previous implementation,
when cluster size oscillated around certain values.
More details: https://docs.google.com/a/google.com/document/d/1T0A7GHwNU_w6gpq_eCN166aRth6usbRvxgJJqSZeESU/edit?usp=sharing (shared with kubernetes-sig-instrumentation and kubernetes-sig-autoscaling)
Also, fix the code to actually use poll-period flag.
(PR moved from kubernetes-retired/contrib#2623)