Merge pull request #1559 from firesim/auto-try-later-ami

automatically try newer hotfix versions of AMI in manager
This commit is contained in:
Sagar Karandikar 2023-06-14 11:13:38 -07:00 committed by GitHub
commit 0d65107358
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 2 deletions

View File

@ -50,6 +50,22 @@ def get_f1_ami_name() -> str:
print("Unknown $USER (expected centos/amzn). Defaulting to the Centos AWS EC2 AMI.")
return "FPGA Developer AMI - 1.12.2-40257ab5-6688-4c95-97d1-e251a40fd1fc"
def get_incremented_f1_ami_name(ami_name: str, increment: int) -> str:
""" For an ami_name of the format "STUFF - X.Y.Z-hash-stuff",
return ami_name, but with Z incremented by increment for auto-bumping
the AMI on hotfix releases. """
base_name = get_f1_ami_name()
split1 = base_name.split(" - ")
prefix = split1[0] + " - "
split2 = split1[1].split("-")
suffix = "-" + "-".join(split2[1:])
version_number = list(map(int, split2[0].split(".")))
version_number[-1] += increment
version_number_str = ".".join(map(str, version_number))
return prefix + version_number_str + suffix
class MockBoto3Instance:
""" This is used for testing without actually launching instances. """
@ -286,13 +302,23 @@ def awsinit() -> None:
else:
rootLogger.info("You did not supply an email address. No notifications will be sent.")
# AMIs are region specific
def get_f1_ami_id() -> str:
""" Get the AWS F1 Developer AMI by looking up the image name -- should be region independent.
"""
client = boto3.client('ec2')
response = client.describe_images(Filters=[{'Name': 'name', 'Values': [get_f1_ami_name()]}])
# Try up to MAX_ATTEMPTS additional hotfix versions of an AMI if the
# initial one fails.
MAX_ATTEMPTS = 10
for increment in range(MAX_ATTEMPTS):
ami_search_name = get_incremented_f1_ami_name(get_f1_ami_name(), increment)
if increment > 0:
rootLogger.warning(f"AMI {get_f1_ami_name()} not found. Trying: {ami_search_name}.")
response = client.describe_images(Filters=[{'Name': 'name', 'Values': [ami_search_name]}])
if len(response['Images']) >= 1:
if increment > 0:
rootLogger.warning(f"AMI {get_f1_ami_name()} not found. Successfully found: {ami_search_name}.")
break
assert len(response['Images']) == 1
return response['Images'][0]['ImageId']

View File

@ -35,6 +35,7 @@ To launch a manager instance, follow these steps:
``FPGA Developer AMI - 1.12.2-40257ab5-6688-4c95-97d1-e251a40fd1fc`` and
select the AMI that appears under the **Community AMIs** tab (there
should be only one). **DO NOT USE ANY OTHER VERSION.** For example, **do not** use `FPGA Developer AMI` from the *AWS Marketplace AMIs* tab, as you will likely get an incorrect version of the AMI.
If you find that there are no results for this search, you can try incrementing the last part of the version number in the search string, e.g., ``1.12.2 -> 1.12.3``. Other parts of the search term should be unchanged.
#. In the *Instance Type* drop-down, select the instance type of
your choosing. A good choice is a ``c5.4xlarge`` (16 cores, 32 GiB) or a ``z1d.2xlarge`` (8 cores, 64 GiB).
#. In the *Key pair (login)* drop-down, select the ``firesim`` key pair we setup earlier.
@ -72,6 +73,23 @@ To launch a manager instance, follow these steps:
#. Click the orange *Launch Instance* button.
.. warning::
Recently, some AWS users been having issues with the launch process (after
you click ``Launch Instance``) getting stuck trying to "Subscribe" to the
AMI even when the account is already subscribed. We have been able to
bypass this issue by going to the FPGA Developer AMI page on AWS
Marketplace, clicking subscribe (even if already subscribed), then clicking
"Continue to Configuration", then verify the correct AMI version and
region are selected and click "Continue to Launch". Finally, change
the dropdown that says "Launch from Website" to "Launch through EC2" and
click "Launch". At this point, you will be brought back to
the usual launch instance page, but the AMI will be pre-selected and you
will be able to successfully launch at the end, after updating the rest
of the options as noted above.
Access your instance
~~~~~~~~~~~~~~~~~~~~