in src/slurm_plugin/fleet_manager.py [0:0]
def _launch_instances(self, launch_params):
"""Launch a batch of ec2 instances."""
try:
response = create_fleet(self._region, self._boto3_config, launch_params)
logger.debug("CreateFleet response: %s", response)
instances = response.get("Instances", [])
log_level = logging.WARNING if instances else logging.ERROR
err_list = response.get("Errors", [])
for err in err_list:
logger.log(
log_level,
"Error in CreateFleet request (%s): %s - %s",
response.get("ResponseMetadata", {}).get("RequestId"),
err.get("ErrorCode"),
err.get("ErrorMessage"),
)
instance_ids = [inst_id for instance in instances for inst_id in instance["InstanceIds"]]
instances, partial_instance_ids = self._get_instances_info(instance_ids)
if partial_instance_ids:
logger.error("Unable to retrieve instance info for instances: %s", partial_instance_ids)
if not instances and len(err_list) == 1:
raise LaunchInstancesError(err_list[0].get("ErrorCode"), err_list[0].get("ErrorMessage"))
return {"Instances": instances}
except ClientError as e:
logger.error(
"Failed CreateFleet request (%s): %s - %s",
e.response.get("ResponseMetadata", {}).get("RequestId"),
e.response.get("Error", {}).get("Code"),
e.response.get("Error", {}).get("Message"),
)
raise e