Skip to content

Commit

Permalink
add os dependend root device path for aws (#185)
Browse files Browse the repository at this point in the history
* add os dependend root device path for aws

* adjust error message

* use bigger machine on digitalocean for e2e tests

* use bigger machine on aws for e2e tests
  • Loading branch information
mrIncompetent authored Apr 24, 2018
1 parent ece04be commit 3dbad0b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
20 changes: 18 additions & 2 deletions pkg/cloudprovider/provider/aws/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,19 @@ func getDefaultAMIID(os providerconfig.OperatingSystem, region string) (string,
return id, nil
}

func getDefaultRootDevicePath(os providerconfig.OperatingSystem) (string, error) {
switch os {
case providerconfig.OperatingSystemUbuntu:
return "/dev/sda1", nil
case providerconfig.OperatingSystemCentOS:
return "/dev/sda1", nil
case providerconfig.OperatingSystemCoreos:
return "/dev/xvda", nil
}

return "", fmt.Errorf("no default root path found for %s operating system", os)
}

func (p *provider) getConfig(s runtime.RawExtension) (*Config, *providerconfig.Config, error) {
pconfig := providerconfig.Config{}
err := json.Unmarshal(s.Raw, &pconfig)
Expand Down Expand Up @@ -530,8 +543,11 @@ func (p *provider) Create(machine *v1alpha1.Machine, userdata string) (instance.
return nil, err
}
securityGroupIDs = append(securityGroupIDs, sgID)
} else {
}

rootDevicePath, err := getDefaultRootDevicePath(pc.OperatingSystem)
if err != nil {
return nil, err
}

amiID := config.AMI
Expand Down Expand Up @@ -568,7 +584,7 @@ func (p *provider) Create(machine *v1alpha1.Machine, userdata string) (instance.
ImageId: aws.String(amiID),
BlockDeviceMappings: []*ec2.BlockDeviceMapping{
{
DeviceName: aws.String("/dev/xvda"),
DeviceName: aws.String(rootDevicePath),
Ebs: &ec2.EbsBlockDevice{
VolumeSize: aws.Int64(config.DiskSize),
DeleteOnTermination: aws.Bool(true),
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/provisioning/testdata/machine-aws.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ spec:
region: "eu-west-2"
availabilityZone: "eu-west-2a"
vpcId: "vpc-40827629"
instanceType: "t2.micro"
instanceType: "t2.medium"
diskSize: 50
diskType: "standard"
diskType: "gp2"
tags:
# you have to set this flag to real clusterID when running against our dev or prod
# otherwise you might have issues with your nodes not joining the cluster
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/provisioning/testdata/machine-digitalocean.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
cloudProviderSpec:
token: << DIGITALOCEAN_TOKEN >>
region: fra1
size: 1gb
size: c-2
backups: false
ipv6: false
private_networking: true
Expand Down

0 comments on commit 3dbad0b

Please sign in to comment.