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

Dynamically lookup the RootDeviceName of the AMI being used #779

Merged
merged 10 commits into from
May 10, 2019
Merged

Dynamically lookup the RootDeviceName of the AMI being used #779

merged 10 commits into from
May 10, 2019

Conversation

adamjohnson01
Copy link
Contributor

@adamjohnson01 adamjohnson01 commented May 3, 2019

Description

The cfn/builder/nodegroup.go was using a hardcoded value for DeviceName. This meant it was not possible to manage the size of the root volume for AMIs that did not use /dev/xvda as the RootDeviceName. I have added a lookup function that will retrieve the value from the AMI being used and populate the value in the launchTemplateData.BlockDeviceMappings.

Closes #774

Checklist

  • Code compiles correctly (i.e make build)
  • All unit tests passing (i.e. make test)
  • All integration tests passing (i.e. make integration-test)
  • Added yourself to the humans.txt file

Copy link
Contributor

@errordeveloper errordeveloper left a comment

Choose a reason for hiding this comment

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

Thank you! It is looking good, just a few minor comments...

pkg/apis/eksctl.io/v1alpha5/types.go Outdated Show resolved Hide resolved
pkg/ami/api.go Outdated Show resolved Hide resolved
pkg/ctl/create/cluster.go Outdated Show resolved Hide resolved
Added length check to the results in LookupRootDeviceName
Moved the root device lookup into ctl.EnsureAMI
pkg/ami/api.go Outdated Show resolved Hide resolved
pkg/eks/api.go Outdated Show resolved Hide resolved
pkg/ami/api.go Outdated Show resolved Hide resolved
pkg/ami/api.go Outdated Show resolved Hide resolved
@adamjohnson01
Copy link
Contributor Author

adamjohnson01 commented May 8, 2019

@errordeveloper as the ami.IsAvailable function can also provide the info that I am looking up in my function, how about merging them, something like this?

func IsAvailable(api ec2iface.EC2API, id string) (bool, string, string, error) {
	input := &ec2.DescribeImagesInput{
		ImageIds: []*string{&id},
	}

	output, err := api.DescribeImages(input)
	if err != nil {
		return false, "", "", errors.Wrapf(err, "unable to find %q", id)
	}

	if len(output.Images) < 1 {
		return false, "", "", nil
	}

	return *output.Images[0].State == "available", *output.Images[0].RootDeviceName, *output.Images[0].RootDeviceType, nil
}

We could then check if the type is instance-store and error if VolumeSize has also been set.
Something like this

	// Check the AMI is available
	available, devName, devType, err := ami.IsAvailable(c.Provider.EC2(), ng.AMI)
	if err != nil {
		return errors.Wrapf(err, "%s is not available", ng.AMI)
	}

	if !available {
		return ami.NewErrNotFound(ng.AMI)
	}

	if devType == "instance-store" && ng.VolumeSize > 0 {
		return errors.Wrap(err, "Cannot set Volume Size for instance-store AMIs")
	}

	if devType == "ebs" {
		ng.VolumeName = devName
	}

@errordeveloper
Copy link
Contributor

Thanks, Adam! This is looking good.

pkg/eks/api.go Outdated Show resolved Hide resolved
@adamjohnson01
Copy link
Contributor Author

Please let me know if there is anything else I need to do.

@errordeveloper
Copy link
Contributor

@adamjohnson01 do you want to make sure all of your commits show up with your profile image? This usually comes down to email address being use in the commit.

@adamjohnson01
Copy link
Contributor Author

@errordeveloper, I have added the email in my commits to my profile now. Thanks!

pkg/eks/api.go Outdated Show resolved Hide resolved
Copy link
Contributor

@errordeveloper errordeveloper left a comment

Choose a reason for hiding this comment

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

Just one last suggestion! :)

@adamjohnson01
Copy link
Contributor Author

adamjohnson01 commented May 10, 2019

Just one last suggestion! :)

@errordeveloper. No problem, that is done now.

errordeveloper
errordeveloper previously approved these changes May 10, 2019
Copy link
Contributor

@errordeveloper errordeveloper left a comment

Choose a reason for hiding this comment

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

This looks great, to thanks a lot! I will have another look, but will push any changes myself before merging - just stuff that maybe quicker to do then explain. Thanks again :)

@errordeveloper errordeveloper merged commit e898b83 into eksctl-io:master May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dynamically lookup DeviceName for AMIs
3 participants