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

Add support for multiple block device mappings #299

Merged
merged 1 commit into from Jun 17, 2020
Merged

Add support for multiple block device mappings #299

merged 1 commit into from Jun 17, 2020

Conversation

alexander-demicev
Copy link

This PR adds support for multiple block device mappings. The problem it solves is that machine is always created with only one disk. One of the use cases is the ability to store logs, empty dir pods data or docker images in a separate place and not have it in root one.

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Feb 25, 2020
Copy link

@elmiko elmiko left a comment

Choose a reason for hiding this comment

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

lgtm, i just have a question inline

Encrypted: blockDeviceMappingSpec.EBS.Encrypted,
},
}
if *volumeType == "io1" {
Copy link

Choose a reason for hiding this comment

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

should we have this "io1" value a constant somewhere so it doesn't seem like a magic value ?

Copy link
Author

Choose a reason for hiding this comment

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

good question :)

Copy link

@michaelgugino michaelgugino left a comment

Choose a reason for hiding this comment

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

How are we sure these devices get cleaned up when we delete an instance?

volumeType := blockDeviceMappingSpec.EBS.VolumeType

blockDeviceMapping := ec2.BlockDeviceMapping{
DeviceName: deviceName,

Choose a reason for hiding this comment

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

This is going to attempt to give all devices the same name.

Choose a reason for hiding this comment

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

I think it's expected that DeviceName should always be set apart from on the root device, though I don't think there's any validation on that at all since these aren't CRDs and we don't have schemas or webhooks for them.

Perhaps we can do validation here and return an error if more than one of the block device mappings doesn't have a name set?

Copy link
Author

Choose a reason for hiding this comment

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

@JoelSpeed I thought of this but wasn't sure that's a right thing to do in that case

Choose a reason for hiding this comment

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

Given we don't have any webhooks set up and we use a rawextension, I'm not sure what else we can do, I may well be missing something though, there may be a better way

Choose a reason for hiding this comment

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

We don't need webhooks. We can just fail the machine's reconcile and quit attempting. I consider this an advanced usecase, so the user better follow the docs and set it up correctly. This will probably also require investigation from the user to determine what a valid block device name is for their instance type.

Choose a reason for hiding this comment

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

Coming back to this, we should make sure the PR that is adding webhooks should validate this, or we should follow up to update that (cc @enxebre)

Copy link
Member

@enxebre enxebre Jun 3, 2020

Choose a reason for hiding this comment

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

Captured this here -> https://github.com/openshift/machine-api-operator/pull/601/files#diff-98bc71b7347ada0763f9e57ae6c9d235R320
Regardless this should error and return and invalid config which the machine controller can use to fail. This seems to be case already.

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Feb 25, 2020
volumeType := blockDeviceMappingSpec.EBS.VolumeType

if blockDeviceMappingSpec.DeviceName == nil {
if onlyOneEmptyDeviceName {

Choose a reason for hiding this comment

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

I think this name could be a little confusing maybe, since we go into this if statement if there is more than one empty device name. Perhaps rootDeviceFound could be a better name?

Copy link
Author

Choose a reason for hiding this comment

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

👍

@alexander-demicev
Copy link
Author

/retest

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 16, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 2, 2020
@JoelSpeed
Copy link

Just re-reviewed, I'm happy with it code wise, left a comment re validation


if blockDeviceMappingSpec.DeviceName == nil {
if rootDeviceFound {
return nil, errors.New("more than one block device doesn't have a name")
Copy link
Member

Choose a reason for hiding this comment

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

may be "non root device must have deviceName"

Copy link
Member

@enxebre enxebre Jun 3, 2020

Choose a reason for hiding this comment

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

Can we please document with a comment in the API BlockDeviceMappingSpec definition https://github.com/openshift/cluster-api-provider-aws/blob/master/pkg/apis/awsprovider/v1beta1/awsproviderconfig_types.go#L86 that a block device with out a deviceName will be used for the root device and only one with no deviceName is allowed.

}

if *volumeType == ec2.VolumeTypeIo1 {
blockDeviceMapping.Ebs.Iops = blockDeviceMappingSpecs[0].EBS.Iops
Copy link
Member

@enxebre enxebre Jun 3, 2020

Choose a reason for hiding this comment

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

why is this and below setting from blockDeviceMappingSpecs[0]? shouldn't it use blockDeviceMappingSpec?

Copy link
Author

Choose a reason for hiding this comment

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

👍 leftover after rebase

}

if aws.StringValue(blockDeviceMappingSpecs[0].EBS.KMSKey.ID) != "" {
klog.V(3).Infof("Using KMS key ID %q for encrypting EBS volume", *blockDeviceMappingSpecs[0].EBS.KMSKey.ID)
Copy link
Member

Choose a reason for hiding this comment

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

s/ blockDeviceMappingSpecs[0] / blockDeviceMappingSpecs ?

Copy link
Author

Choose a reason for hiding this comment

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

thanks, fixed

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

right, fixed

@enxebre
Copy link
Member

enxebre commented Jun 17, 2020

/approve

@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: enxebre

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 17, 2020
@enxebre
Copy link
Member

enxebre commented Jun 17, 2020

Copy link

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 17, 2020
@openshift-merge-robot openshift-merge-robot merged commit 265fc0c into openshift:master Jun 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release/4.6 size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants