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

Rewrite addon-resizer nanny #128

Merged
merged 2 commits into from
Jun 21, 2017
Merged

Rewrite addon-resizer nanny #128

merged 2 commits into from
Jun 21, 2017

Conversation

x13n
Copy link
Member

@x13n x13n commented Jun 20, 2017

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)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 20, 2017
@x13n
Copy link
Member Author

x13n commented Jun 20, 2017

/assign @mwielgus

@@ -25,7 +25,7 @@
OUT_DIR = build
PACKAGE = k8s.io/contrib/addon-resizer
PREFIX = gcr.io/google_containers
TAG = 1.7
TAG = 1.8
Copy link
Contributor

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok.


log "github.com/golang/glog"
Copy link
Contributor

@mwielgus mwielgus Jun 20, 2017

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

Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

wrong import order

Copy link
Member Author

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.

@x13n x13n force-pushed the master branch 2 times, most recently from db94731 to a4440c3 Compare June 20, 2017 10:18
Resources []Resource
// ResourceListPair is a pair of ResourceLists, denoting a range.
type ResourceListPair struct {
lower, upper api.ResourceList
Copy link
Contributor

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.

return calculateResources(numNodes, e.Resources)
// EstimatorResult is the result of the resource Estimation, used by Estimator struct.
type EstimatorResult struct {
RecommendedRange, AcceptableRange ResourceListPair
Copy link
Contributor

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.

ScaleFactor float64
// Estimator is a struct used for estimating accepted and recommended resource requirements.
type Estimator struct {
Resources []Resource
Copy link
Contributor

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

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

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

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

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" {
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Remove.

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

@mwielgus mwielgus Jun 20, 2017

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.

@mwielgus
Copy link
Contributor

Please explain how the PR was tested.

@x13n x13n force-pushed the master branch 2 times, most recently from 9ff39be to 7df7cde Compare June 20, 2017 14:32
@x13n
Copy link
Member Author

x13n commented Jun 20, 2017

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.

@mwielgus
Copy link
Contributor

Doesn't compile.

x13n added 2 commits June 21, 2017 10:48
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.
@x13n
Copy link
Member Author

x13n commented Jun 21, 2017

Does compile.

@mwielgus
Copy link
Contributor

Fixes kubernetes/kubernetes#30446.

@mwielgus
Copy link
Contributor

LGTM

@mwielgus mwielgus added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 21, 2017
@mwielgus mwielgus merged commit ff9ac8e into kubernetes:master Jun 21, 2017
JoelSpeed pushed a commit to JoelSpeed/autoscaler that referenced this pull request May 13, 2020
…rry-pick-125-to-release-4.4

[release-4.4] BUG 1805153: Ensure DeleteNodes doesn't delete a node twice
yaroslava-serdiuk pushed a commit to yaroslava-serdiuk/autoscaler that referenced this pull request Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/addon-resizer cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants