Chromium Code Reviews| Index: appengine/gce-backend/instance_group_managers.py |
| diff --git a/appengine/gce-backend/instance_group_managers.py b/appengine/gce-backend/instance_group_managers.py |
| index e8ab6410d1395d7fdd94fe7186d3317a18459777..ffd3ecd0cbd7615f01eaef81185dc36a6c0b1746 100644 |
| --- a/appengine/gce-backend/instance_group_managers.py |
| +++ b/appengine/gce-backend/instance_group_managers.py |
| @@ -309,11 +309,18 @@ def resize(key): |
| api = gce.Project(parent.project) |
| response = api.get_instance_group_manager(get_name(entity), key.id()) |
| + # Find out how many VMs are created (i.e. not currently being created |
|
Vadim Sh.
2016/07/20 20:57:23
"are idle" ?
smut
2016/07/20 21:00:37
Done.
|
| + # or deleted). This helps avoid doing too many VM actions simultaneously. |
| + current_size = response.get('currentActions', {}).get('none') |
| + if not current_size: |
|
Vadim Sh.
2016/07/20 20:57:23
zero idle VMs is not allowed?..
should it be "if
smut
2016/07/20 21:00:37
True story. Probably not necessary anyway, unless
|
| + logging.error('Unexpected response: %s', json.dumps(response, indent=2)) |
| + return |
| + |
| # Try to reach the target size, but avoid increasing the number of |
| # instances by more than the resize limit. For now, the target size |
| # is just the minimum size. |
| - target_size = min(entity.minimum_size, response['targetSize'] + RESIZE_LIMIT) |
| - if response['targetSize'] >= target_size: |
| + target_size = min(entity.minimum_size, current_size + RESIZE_LIMIT) |
| + if current_size >= target_size: |
| return |
| api.resize_managed_instance_group(response['name'], key.id(), target_size) |