mirror of https://github.com/kubernetes/kops.git
- fixing up the root volume detection, similar to what we did on additional volumes
This commit is contained in:
parent
74af751dc6
commit
770cde669f
|
|
@ -122,7 +122,7 @@ func (i *BlockDeviceMapping) ToAutoscaling(deviceName string) *autoscaling.Block
|
|||
}
|
||||
|
||||
// BlockDeviceMappingFromLaunchTemplateBootDeviceRequest coverts the launch template device mappings to an interval block device mapping
|
||||
func BlockDeviceMappingFromLaunchTemplateBootDeviceRequest(i *ec2.LaunchTemplateBlockDeviceMappingRequest) (string, *BlockDeviceMapping) {
|
||||
func BlockDeviceMappingFromLaunchTemplateBootDeviceRequest(i *ec2.LaunchTemplateBlockDeviceMapping) (string, *BlockDeviceMapping) {
|
||||
o := &BlockDeviceMapping{}
|
||||
o.VirtualName = i.VirtualName
|
||||
if i.Ebs != nil {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ limitations under the License.
|
|||
package awstasks
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
|
|
@ -38,3 +39,18 @@ func buildEphemeralDevices(cloud awsup.AWSCloud, machineType string) (map[string
|
|||
|
||||
return blockDeviceMappings, nil
|
||||
}
|
||||
|
||||
// buildAdditionalDevices is responsible for creating additional volumes in this lc
|
||||
func buildAdditionalDevices(volumes []*BlockDeviceMapping) (map[string]*BlockDeviceMapping, error) {
|
||||
devices := make(map[string]*BlockDeviceMapping, 0)
|
||||
|
||||
// @step: iterate the volumes and create devices from them
|
||||
for _, x := range volumes {
|
||||
if x.DeviceName == nil {
|
||||
return nil, errors.New("DeviceName not set for volume")
|
||||
}
|
||||
devices[*x.DeviceName] = x
|
||||
}
|
||||
|
||||
return devices, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ package awstasks
|
|||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"sort"
|
||||
|
|
@ -235,21 +234,6 @@ func (e *LaunchConfiguration) Find(c *fi.Context) (*LaunchConfiguration, error)
|
|||
return actual, nil
|
||||
}
|
||||
|
||||
// buildAdditionalDevices is responsible for creating additional volumes in this lc
|
||||
func buildAdditionalDevices(volumes []*BlockDeviceMapping) (map[string]*BlockDeviceMapping, error) {
|
||||
devices := make(map[string]*BlockDeviceMapping, 0)
|
||||
|
||||
// @step: iterate the volumes and create devices from them
|
||||
for _, x := range volumes {
|
||||
if x.DeviceName == nil {
|
||||
return nil, errors.New("DeviceName not set for volume")
|
||||
}
|
||||
devices[*x.DeviceName] = x
|
||||
}
|
||||
|
||||
return devices, nil
|
||||
}
|
||||
|
||||
func (e *LaunchConfiguration) Run(c *fi.Context) error {
|
||||
// TODO: Make Normalize a standard method
|
||||
e.Normalize()
|
||||
|
|
|
|||
|
|
@ -202,14 +202,26 @@ func (t *LaunchTemplate) Find(c *fi.Context) (*LaunchTemplate, error) {
|
|||
}
|
||||
sort.Sort(OrderSecurityGroupsById(actual.SecurityGroups))
|
||||
|
||||
// @step: get the image is order to find out the root device name as using the index
|
||||
// is not vaiable, under conditions they move
|
||||
image, err := cloud.ResolveImage(fi.StringValue(t.ImageID))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// @step: find the root volume
|
||||
for _, b := range lt.LaunchTemplateData.BlockDeviceMappings {
|
||||
if b.Ebs == nil || b.Ebs.SnapshotId != nil {
|
||||
if b.Ebs == nil {
|
||||
continue
|
||||
}
|
||||
actual.RootVolumeSize = b.Ebs.VolumeSize
|
||||
actual.RootVolumeType = b.Ebs.VolumeType
|
||||
actual.RootVolumeIops = b.Ebs.Iops
|
||||
if b.DeviceName != nil && fi.StringValue(b.DeviceName) == fi.StringValue(image.RootDeviceName) {
|
||||
actual.RootVolumeSize = b.Ebs.VolumeSize
|
||||
actual.RootVolumeType = b.Ebs.VolumeType
|
||||
actual.RootVolumeIops = b.Ebs.Iops
|
||||
} else {
|
||||
_, d := BlockDeviceMappingFromLaunchTemplateBootDeviceRequest(b)
|
||||
actual.BlockDeviceMappings = append(actual.BlockDeviceMappings, d)
|
||||
}
|
||||
}
|
||||
|
||||
if lt.LaunchTemplateData.UserData != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue