Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Unified Diff: appengine/gce-backend/instance_group_managers.py

Issue 2163413002: Look at the current number of idle VMs during resize logic (Closed) Base URL: https://github.com/luci/luci-py.git@master
Patch Set: Fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..d9f4980557fbe752cce464ec4288eb155a3b0ca7 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 idle (i.e. not currently being created
+ # or deleted). This helps avoid doing too many VM actions simultaneously.
+ current_size = response.get('currentActions', {}).get('none')
+ if current_size is None:
+ 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)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698