Skip to content
This repository has been archived by the owner on Dec 24, 2019. It is now read-only.

Commit

Permalink
More logging when slowing down downscaling (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjacobs committed Dec 16, 2017
1 parent 53a7dd1 commit a48b2b0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
language: python
python:
- "3.5"
- "3.6"
install:
- pip install tox tox-travis coveralls
script:
Expand Down
14 changes: 8 additions & 6 deletions kube_aws_autoscaler/main.py
Expand Up @@ -208,15 +208,17 @@ def slow_down_downscale(asg_sizes: dict, nodes_by_asg_zone: dict, scale_down_ste
node_counts_by_asg[asg_name] += len(nodes)

for asg_name, desired_size in sorted(asg_sizes.items()):
amount_of_downscale = node_counts_by_asg[asg_name] - desired_size
current_size = node_counts_by_asg[asg_name]
amount_of_downscale = current_size - desired_size
if amount_of_downscale >= 2:
new_desired_size_fixed = node_counts_by_asg[asg_name] - scale_down_step_fixed
new_desired_size_percentage = max(desired_size, int(math.ceil((1.00 - scale_down_step_percentage) * node_counts_by_asg[asg_name])))
if new_desired_size_percentage == node_counts_by_asg[asg_name]:
new_desired_size_fixed = current_size - scale_down_step_fixed
new_desired_size_percentage = max(desired_size, int(math.ceil((1.00 - scale_down_step_percentage) * current_size)))
if new_desired_size_percentage >= current_size:
# percentage amount is too small, make sure we downscale by fixed amount at least
new_desired_size_percentage = new_desired_size_fixed
new_desired_size = min(new_desired_size_fixed, new_desired_size_percentage)

logger.info('Slowing down downscale: changing desired size of ASG {} from {} to {}'.format(asg_name, desired_size, new_desired_size))
logger.info('Slowing down downscale: changing desired size of ASG {} (current size is {}) from {} to {}'.format(
asg_name, current_size, desired_size, new_desired_size))
asg_sizes[asg_name] = new_desired_size

return asg_sizes
Expand Down
4 changes: 2 additions & 2 deletions tox.ini
@@ -1,8 +1,8 @@
[tox]
envlist=py35,flake8
envlist=py36,flake8

[tox:travis]
3.5=py35,flake8
3.6=py36,flake8

[testenv]
deps=pytest
Expand Down

0 comments on commit a48b2b0

Please sign in to comment.