[Provider/aws] use strings.TrimPrefix()

This commit is contained in:
Gaurav Singh 2020-04-21 11:21:40 -04:00
parent d6f44b0ea9
commit 033f94e58a

View File

@ -1884,12 +1884,8 @@ func (c *Cloud) getMountDevice(
volumeStatus := map[EBSVolumeID]string{} // for better logging of volume status
for _, blockDevice := range info.BlockDeviceMappings {
name := aws.StringValue(blockDevice.DeviceName)
if strings.HasPrefix(name, "/dev/sd") {
name = name[7:]
}
if strings.HasPrefix(name, "/dev/xvd") {
name = name[8:]
}
name = strings.TrimPrefix(name, "/dev/sd")
name = strings.TrimPrefix(name, "/dev/xvd")
if len(name) < 1 || len(name) > 2 {
klog.Warningf("Unexpected EBS DeviceName: %q", aws.StringValue(blockDevice.DeviceName))
}