Prevent instance assignment from falling below min
@@ -5794,11 +5794,8 @@ HOSTS
# Make sure we leave at least the minimum number of AppServers
# running.
- if delta_appservers > @app_info_map[app_name]['appengine'].length + min
- num_to_remove = @app_info_map[app_name]['appengine'].length - min
- else
- num_to_remove = delta_appservers
- end
+ max_delta = @app_info_map[app_name]['appengine'].length - min
+ num_to_remove = [delta_appservers, max_delta].min
# Let's pick the latest appengine node hosting the application and
# remove the AppServer there, so we can try to reclaim it once it's
