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

Skip instance_type selection if type is already set #262

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions igvm/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from fabric.contrib.files import upload_template
from fabric.exceptions import NetworkError
from json.decoder import JSONDecodeError
from urllib.error import HTTPError
from urllib.error import HTTPError, URLError
from urllib.request import Request, urlopen

from igvm.exceptions import ConfigError, HypervisorError, RemoteCommandError, VMError
Expand Down Expand Up @@ -713,12 +713,21 @@ def aws_build(self,
:raises: VMError: Generic exception for VM errors of all kinds
"""

vm_types_overview = self.aws_get_instances_overview()
if vm_types_overview:
vm_types = self.aws_get_fitting_vm_types(vm_types_overview)
# The current solution for figuring out the best instance_type is not
# scalable for the disaster recovery case because we are parsing a
# 70 MB big json file in parallel for every VM. We are currently working
# on a different solution to prefill the instance_type for the disaster
# recovery case. We'll keep the functionality in igvm for now to be able
# to build VMs in AWS without the need of a prefill.
Copy link
Contributor

Choose a reason for hiding this comment

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

What is exactly the problem here? Is it loading the json file into Python structures or parsing those structures?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The memory footprint of loading the file is too big. Building 10 machines in parallel that way, the server allocates more then 2GiB of memory and we want to be able to build at least 50 VMs in parallel on one server.

if self.dataset_obj['aws_instance_type']:
vm_types = [self.dataset_obj['aws_instance_type']]
else:
vm_types = [AWS_FALLBACK_INSTANCE_TYPE]
self.dataset_obj['aws_instance_type'] = vm_types[0]
vm_types_overview = self.aws_get_instances_overview()
if vm_types_overview:
vm_types = self.aws_get_fitting_vm_types(vm_types_overview)
else:
vm_types = [AWS_FALLBACK_INSTANCE_TYPE]
self.dataset_obj['aws_instance_type'] = vm_types[0]

self.check_serveradmin_config()

Expand Down Expand Up @@ -1221,7 +1230,7 @@ def aws_get_instances_overview(
f.write(content)

return json.loads(content)
except (HTTPError, JSONDecodeError) as e:
except (HTTPError, JSONDecodeError, URLError) as e:
log.warning('Could not retrieve instances overview')
log.warning(e)
log.info('Proceeding with instance_type: '
Expand Down