From 6d48d2ef2a00abd7f1bfe6f452e3cbc1cf991743 Mon Sep 17 00:00:00 2001 From: Sagar Karandikar Date: Tue, 13 Jun 2023 17:00:31 -0700 Subject: [PATCH 1/4] auto try later AMI --- deploy/awstools/awstools.py | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/deploy/awstools/awstools.py b/deploy/awstools/awstools.py index 18b98621..35f92516 100755 --- a/deploy/awstools/awstools.py +++ b/deploy/awstools/awstools.py @@ -48,7 +48,23 @@ def get_f1_ami_name() -> str: else: if cuser != "centos": 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" + return "FPGA Developer AMI - 1.12.1-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 = ".".join(map(str, version_number)) + return prefix + version_number + 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'] From 9422fbe730e7ed38581d4e3cea28bf9969b3f6af Mon Sep 17 00:00:00 2001 From: Sagar Karandikar Date: Tue, 13 Jun 2023 17:34:36 -0700 Subject: [PATCH 2/4] update docs --- deploy/awstools/awstools.py | 2 +- .../Setting-up-your-Manager-Instance.rst | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/deploy/awstools/awstools.py b/deploy/awstools/awstools.py index 35f92516..77862ca4 100755 --- a/deploy/awstools/awstools.py +++ b/deploy/awstools/awstools.py @@ -48,7 +48,7 @@ def get_f1_ami_name() -> str: else: if cuser != "centos": print("Unknown $USER (expected centos/amzn). Defaulting to the Centos AWS EC2 AMI.") - return "FPGA Developer AMI - 1.12.1-40257ab5-6688-4c95-97d1-e251a40fd1fc" + 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", diff --git a/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst b/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst index 950ac747..2636fc72 100644 --- a/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst +++ b/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst @@ -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,22 @@ 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), and then + following the prompts about launching an instance until you get to the + point where you can select "Launch via EC2" in a dropdown. Once you click + continue on the page with "Launch via EC2", 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 ~~~~~~~~~~~~~~~~~~~~ From f4ee1ad384f36f4085f04e23d5f9de640b227894 Mon Sep 17 00:00:00 2001 From: Sagar Karandikar Date: Tue, 13 Jun 2023 21:32:23 -0700 Subject: [PATCH 3/4] make the type checker happy --- deploy/awstools/awstools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/awstools/awstools.py b/deploy/awstools/awstools.py index 77862ca4..bb4e1058 100755 --- a/deploy/awstools/awstools.py +++ b/deploy/awstools/awstools.py @@ -63,8 +63,8 @@ def get_incremented_f1_ami_name(ami_name: str, increment: int) -> str: version_number = list(map(int, split2[0].split("."))) version_number[-1] += increment - version_number = ".".join(map(str, version_number)) - return prefix + version_number + suffix + 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. """ From d62a4e25a519201a08bf31f69e72a71e4e78168b Mon Sep 17 00:00:00 2001 From: Sagar Karandikar Date: Wed, 14 Jun 2023 11:10:32 -0700 Subject: [PATCH 4/4] improve warning [ci-skip] --- .../Initial-Setup/Setting-up-your-Manager-Instance.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst b/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst index 2636fc72..88593c89 100644 --- a/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst +++ b/docs/Getting-Started-Guides/AWS-EC2-F1-Tutorial/Initial-Setup/Setting-up-your-Manager-Instance.rst @@ -79,10 +79,11 @@ To launch a manager instance, follow these steps: 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), and then - following the prompts about launching an instance until you get to the - point where you can select "Launch via EC2" in a dropdown. Once you click - continue on the page with "Launch via EC2", you will be brought back to + 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.