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

Amazon Images for Aarch64 #62042

Merged
merged 5 commits into from Sep 4, 2019
Merged

Conversation

thefloweringash
Copy link
Member

@thefloweringash thefloweringash commented May 25, 2019

Motivation for this change

AMIs for Amazon's A1 instance type. Following advice from #nixos-dev, this adds a hydra job to build the images, and a script that will upload and register the prebuilt images given the store path. The uploader does not require a configured aarch64 builder.

While rewriting the create-amis.sh script I only used the awscli package. I haven't seen it written anywhere, but it seems like the ec2-* tools do not support current AWS features like session tokens and assume-role based access to s3. I find this version more compatible with my authentication scheme (short lived tokens), but recognize this is a large change from the existing behavior.

Configuration details adapted from #52779

Tested booting both "arm64" and "x86_64" images produced from nix-build nixos/release.nix -A amazon_image.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@@ -51,7 +51,9 @@ in {
inherit lib config;
inherit (cfg) contents format name;
pkgs = import ../../../.. { inherit (pkgs) system; }; # ensure we use the regular qemu-kvm package
partitionTableType = if config.ec2.hvm then "legacy" else "none";
partitionTableType = if config.ec2.efi then "efi"
else if config.ec2.hvm then "legacy"
Copy link
Member Author

Choose a reason for hiding this comment

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

ec2.hvm is blocked by an assertion, but the implementation still seems to support it. I preserved the existing behavior.

@@ -61,6 +63,9 @@ in {
${optionalString config.ec2.hvm ''
ec2.hvm = true;
''}
${optionalString config.ec2.efi ''
ec2.efi = true;
Copy link
Member Author

Choose a reason for hiding this comment

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

Implemented in the same pattern as ec2.hvm, but I don't know the reason for this.

@@ -25,6 +25,9 @@ in
{ assertion = cfg.hvm;
message = "Paravirtualized EC2 instances are no longer supported.";
}
{ assertion = cfg.efi -> cfg.hvm;
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know if this is a strict requirement, but it reduces the possible configurations to support.

@samueldr samueldr requested a review from edolstra May 31, 2019 15:59
@thefloweringash thefloweringash changed the title amazon-image.nix: add EFI support, enable by default for aarch64 Amazon Images for Aarch64 May 31, 2019
@memberbetty
Copy link
Contributor

If you can add some documentation too, which would make it possible to use this in 10 minutes, this is the kind of thing that would make me want to run master.

Great to see arm support coming, regardless.

us-east-1 us-east-2 us-west-1 us-west-2
ca-central-1
ap-southeast-1 ap-southeast-2 ap-northeast-1 ap-northeast-2
ap-south-1 ap-east-1
Copy link
Member Author

Choose a reason for hiding this comment

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

ap-east-1 is new here, and may required additional configuration to enable this region

Copy link
Member

Choose a reason for hiding this comment

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

I don't think we have to do any region-specific configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

Some regions can be individually disabled and enabled, see the Amazon docs on Managing AWS Regions. I think ap-east-1 is the only region that this applies to, and is disabled by default.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, looks like ap-east-1 and me-south-1 are currently disabled.


# configuration
state_dir=/home/deploy/amis/ec2-images
home_region=us-west-2
Copy link
Member Author

Choose a reason for hiding this comment

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

I can't tell the home region of the nixos-amis bucket, this is probably wrong.

Copy link
Member

Choose a reason for hiding this comment

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

It's in eu-west-1 (or EU if it needs the old S3 location constraint).

@thefloweringash thefloweringash force-pushed the aarch64-ami branch 2 times, most recently from fe34388 to 65e0249 Compare June 4, 2019 15:49
@@ -196,6 +196,22 @@ in rec {
);


# A disk image that can be imported to Amazon EC2 and registered as an AMI
amazon_image = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system:
Copy link
Member

Choose a reason for hiding this comment

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

amazon_image -> amazonImage.

@@ -42,7 +42,7 @@ in {

format = mkOption {
type = types.enum [ "raw" "qcow2" "vpc" ];
default = "qcow2";
default = "vpc";
Copy link
Member

Choose a reason for hiding this comment

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

Is vpc a sparse / compressed disk format? For Hydra it's important not to increase the size of the images a lot.

Copy link
Member Author

Choose a reason for hiding this comment

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

I believe it's sparse but not compressed, comparisons:

└── [ 1193577472]  nixos-amazon-image-19.09pre130979.gfedcba-aarch64-linux.vhd
└── [ 1177550848]  nixos-amazon-image-19.09pre130979.gfedcba-aarch64-linux.qcow2
└── [ 1132745216]  nixos-amazon-image-19.09pre130979.gfedcba-x86_64-linux.vhd
└── [ 1116078080]  nixos-amazon-image-19.09pre130979.gfedcba-x86_64-linux.qcow2

@thefloweringash thefloweringash force-pushed the aarch64-ami branch 2 times, most recently from d82bec8 to ec7d1db Compare June 4, 2019 16:47
@edolstra
Copy link
Member

edolstra commented Sep 4, 2019

@thefloweringash Can you resolve the merge conflict? Then I'll merge this. Thanks!

@thefloweringash
Copy link
Member Author

Rebased on current master. I haven't tested it since the rebase, but the rebase itself was straightforward.

@edolstra edolstra merged commit 68801b4 into NixOS:master Sep 4, 2019
@thefloweringash thefloweringash deleted the aarch64-ami branch September 4, 2019 17:01
@thefloweringash
Copy link
Member Author

thefloweringash commented Sep 4, 2019

I've now successfully tested booting both amd64 and aarch64 AMIs on current master (after fixing the ceph entry in the release notes).

@kirelagin
Copy link
Member

I’m trying to use this image and I am importing it manually (since there seem to be no images on the nixos.org website currently), however the import-image task fails with

"StatusMessage": "ClientError: EFI partition detected. UEFI booting is not supported in EC2.",

🤔

@kirelagin
Copy link
Member

Hm, ok, apparently EFI is specifically for aarch64, and one has to pass --architecture arm64 to import-image, however there is probably something wrong on their end:

An error occurred (InvalidParameter) when calling the ImportImage operation: Parameter architecture=arm64 has an invalid format.

@thefloweringash
Copy link
Member Author

I am importing it manually

one has to pass --architecture arm64 to import-image,

Are you using nixos/maintainers/scripts/ec2/create-amis.sh? It should handle this for you. It's not the best interface, but you can modify the top of script to configure your bucket and regions in order to run it locally.

I've created an aarch64 ami with create-amis.sh and successfully booted an a1.medium on it. If this is still failing for you, can you share more details so I can try to reproduce it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants